Skip to content

Commit

Permalink
V 0.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed May 20, 2024
1 parent 774253e commit c412b9f
Show file tree
Hide file tree
Showing 9 changed files with 428 additions and 65 deletions.
333 changes: 333 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions cmd/tools/changelog_helper.v
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn (mut app App) process_line(text string) ! {
// exit(0)
//}
if (semicolon_pos < 15
&& prefix in ['checker', 'cgen', 'parser', 'v.parser', 'ast', 'jsgen', 'v.gen.js', 'fmt', 'vfmt'])
&& prefix in ['checker', 'cgen', 'parser', 'v.parser', 'ast', 'jsgen', 'v.gen.js', 'fmt', 'vfmt', 'tools'])
|| (semicolon_pos < 30 && prefix.contains(', ')) {
s = '- ' + text[semicolon_pos + 2..].capitalize()
}
Expand Down Expand Up @@ -348,12 +348,6 @@ const db_strings = [
'pg:',
]

const improvements_strings = [
'all:',
'v:',
'coroutines:',
]

const parser_strings = [
'parser:',
'ast:',
Expand All @@ -367,6 +361,7 @@ const stdlib_strings = [
'sync:',
'datatypes:',
'math:',
'math.',
'math.big',
'crypto',
'sokol',
Expand All @@ -376,11 +371,11 @@ const stdlib_strings = [
'toml:',
'vlib:',
'arrays:',
'math.',
'os.',
'term:',
'sync.',
'builtin:',
'builtin,',
'strconv',
'readline',
'cli:',
Expand Down Expand Up @@ -439,6 +434,13 @@ fn is_internal(text string) bool {
return is_xxx(text, internal_strings)
}

const improvements_strings = [
'all:',
'v:',
'coroutines:',
'autofree',
]

fn is_improvements(text string) bool {
return is_xxx(text, improvements_strings)
}
Expand Down Expand Up @@ -469,6 +471,8 @@ const tools_strings = [
'vtest',
'repl',
'REPL',
'vet',
'tools.',
]

fn is_tools(text string) bool {
Expand Down
2 changes: 1 addition & 1 deletion v.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Module {
name: 'V'
description: 'The V programming language.'
version: '0.4.5'
version: '0.4.6'
license: 'MIT'
repo_url: 'https://github.com/vlang/v'
dependencies: []
Expand Down
4 changes: 4 additions & 0 deletions vlib/builtin/int.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ module builtin
// ----- value to string functions -----
//

pub struct VContext {
allocator int
}

// type u8 = byte
type byte = u8

Expand Down
2 changes: 1 addition & 1 deletion vlib/semver/v.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Module {
name: 'semver'
version: '0.4.5'
version: '0.4.6'
deps: []
}
3 changes: 3 additions & 0 deletions vlib/v/checker/errors.v
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ fn (mut c Checker) warn(s string, pos token.Pos) {
}

fn (mut c Checker) error(message string, pos token.Pos) {
if c.fileis('a.v') {
print_backtrace()
}
if (c.pref.translated || c.file.is_translated) && message.starts_with('mismatched types') {
// TODO: move this
return
Expand Down
26 changes: 22 additions & 4 deletions vlib/v/checker/fn.v
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
&& expected_type.idx() != typ.idx() {
expected_type_str := c.table.type_to_str(expected_type)
got_type_str := c.table.type_to_str(typ)
c.error('cannot use `...${got_type_str}` as `...${expected_type_str}` in argument ${
c.error('1cannot use `...${got_type_str}` as `...${expected_type_str}` in argument ${
i + 1} to `${fn_name}`', call_arg.pos)
}
}
Expand Down Expand Up @@ -1329,7 +1329,7 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
if arg_typ !in [ast.voidptr_type, ast.nil_type]
&& !c.check_multiple_ptr_match(arg_typ, param.typ, param, call_arg) {
got_typ_str, expected_typ_str := c.get_string_names_of(arg_typ, param.typ)
c.error('cannot use `${got_typ_str}` as `${expected_typ_str}` in argument ${i + 1} to `${fn_name}`',
c.error('2cannot use `${got_typ_str}` as `${expected_typ_str}` in argument ${i + 1} to `${fn_name}`',
call_arg.pos)
}
continue
Expand Down Expand Up @@ -1435,7 +1435,13 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
continue
}
}
c.error('${err.msg()} in argument ${i + 1} to `${fn_name}`', call_arg.pos)
// if first_sym.name == 'VContext' && f.params[0].name == 'ctx' { // TODO use int comparison for perf
//}
if param_typ_sym.info is ast.Struct && param_typ_sym.name == 'VContext' {
c.note('ok', call_arg.pos)
continue
}
c.error('3${err.msg()} in argument ${i + 1} to `${fn_name}`', call_arg.pos)
}
if final_param_sym.kind == .struct_ && arg_typ !in [ast.voidptr_type, ast.nil_type]
&& !c.check_multiple_ptr_match(arg_typ, param.typ, param, call_arg) {
Expand Down Expand Up @@ -2644,6 +2650,7 @@ fn (mut c Checker) check_expected_arg_count(mut node ast.CallExpr, f &ast.Fn) !
}
if nr_args < min_required_params {
if min_required_params == nr_args + 1 {
// params struct?
last_typ := f.params.last().typ
last_sym := c.table.sym(last_typ)
if last_sym.info is ast.Struct {
Expand All @@ -2658,8 +2665,19 @@ fn (mut c Checker) check_expected_arg_count(mut node ast.CallExpr, f &ast.Fn) !
return
}
}
// Implicit context first arg?
first_typ := f.params[0].typ
first_sym := c.table.sym(first_typ)
if first_sym.info is ast.Struct {
if c.fileis('a.v') {
if first_sym.name == 'VContext' && f.params[0].name == 'ctx' { // TODO use int comparison for perf
// c.error('got ctx ${first_sym.name}', node.pos)
return
}
}
}
}
c.error('expected ${min_required_params} arguments, but got ${nr_args}', node.pos)
c.error('expected ${min_required_params} arguments, but got x${nr_args}', node.pos)
return error('')
} else if !f.is_variadic && nr_args > nr_params {
unexpected_args_pos := node.args[min_required_params].pos.extend(node.args.last().pos)
Expand Down
51 changes: 0 additions & 51 deletions vlib/v/util/version/version.c.v
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
module version

import os

pub const v_version = '0.4.5'

// vhash() returns the build string C.V_COMMIT_HASH . See cmd/tools/gen_vc.v .
pub fn vhash() string {
mut buf := [50]u8{}
Expand All @@ -14,50 +10,3 @@ pub fn vhash() string {
return tos_clone(bp)
}
}

pub fn full_hash() string {
build_hash := vhash()
current_hash := @VCURRENTHASH
if build_hash == current_hash {
return build_hash
}
return '${build_hash}.${current_hash}'
}

// full_v_version() returns the full version of the V compiler
pub fn full_v_version(is_verbose bool) string {
if is_verbose {
return 'V ${version.v_version} ${full_hash()}'
}
return 'V ${version.v_version} ${@VCURRENTHASH}'
}

// githash tries to find the current git commit hash for the specified
// project path by parsing the relevant files in its `.git/` folder.
pub fn githash(path string) !string {
// .git/HEAD
git_head_file := os.join_path(path, '.git', 'HEAD')
if !os.exists(git_head_file) {
return error('failed to find `${git_head_file}`')
}
// 'ref: refs/heads/master' ... the current branch name
head_content := os.read_file(git_head_file) or {
return error('failed to read `${git_head_file}`')
}
current_branch_hash := if head_content.starts_with('ref: ') {
rev_rel_path := head_content.replace('ref: ', '').trim_space()
rev_file := os.join_path(path, '.git', rev_rel_path)
// .git/refs/heads/master
if !os.exists(rev_file) {
return error('failed to find revision file `${rev_file}`')
}
// get the full commit hash contained in the ref heads file
os.read_file(rev_file) or { return error('failed to read revision file `${rev_file}`') }
} else {
head_content
}
desired_hash_length := 7
return current_branch_hash[0..desired_hash_length] or {
error('failed to limit hash `${current_branch_hash}` to ${desired_hash_length} characters')
}
}
52 changes: 52 additions & 0 deletions vlib/v/util/version/version.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module version

import os

pub const v_version = '0.4.6'

pub fn full_hash() string {
build_hash := vhash()
current_hash := @VCURRENTHASH
if build_hash == current_hash {
return build_hash
}
return '${build_hash}.${current_hash}'
}

// full_v_version() returns the full version of the V compiler
pub fn full_v_version(is_verbose bool) string {
if is_verbose {
return 'V ${version.v_version} ${full_hash()}'
}
return 'V ${version.v_version} ${@VCURRENTHASH}'
}

// githash tries to find the current git commit hash for the specified
// project path by parsing the relevant files in its `.git/` folder.
pub fn githash(path string) !string {
// .git/HEAD
git_head_file := os.join_path(path, '.git', 'HEAD')
if !os.exists(git_head_file) {
return error('failed to find `${git_head_file}`')
}
// 'ref: refs/heads/master' ... the current branch name
head_content := os.read_file(git_head_file) or {
return error('failed to read `${git_head_file}`')
}
current_branch_hash := if head_content.starts_with('ref: ') {
rev_rel_path := head_content.replace('ref: ', '').trim_space()
rev_file := os.join_path(path, '.git', rev_rel_path)
// .git/refs/heads/master
if !os.exists(rev_file) {
return error('failed to find revision file `${rev_file}`')
}
// get the full commit hash contained in the ref heads file
os.read_file(rev_file) or { return error('failed to read revision file `${rev_file}`') }
} else {
head_content
}
desired_hash_length := 7
return current_branch_hash[0..desired_hash_length] or {
error('failed to limit hash `${current_branch_hash}` to ${desired_hash_length} characters')
}
}

0 comments on commit c412b9f

Please sign in to comment.