diff --git a/examples/get_weather/get_weather.v b/examples/get_weather/get_weather.v index d08d9da4a9..8c385f33e9 100644 --- a/examples/get_weather/get_weather.v +++ b/examples/get_weather/get_weather.v @@ -12,7 +12,7 @@ struct Weather { timezone string @[skip] server_time u32 @[skip] location []f32 @[skip] - result Result //[json: result] if the field name is different in JSON, it can be specified + result Result //@[json: result] if the field name is different in JSON, it can be specified } struct Result { diff --git a/examples/vweb_orm_jwt/src/auth_dto.v b/examples/vweb_orm_jwt/src/auth_dto.v index 0c2abe6771..22424187fa 100644 --- a/examples/vweb_orm_jwt/src/auth_dto.v +++ b/examples/vweb_orm_jwt/src/auth_dto.v @@ -1,7 +1,7 @@ module main struct AuthRequestDto { - // Adding a [required] attribute will make decoding fail, if that field is not present in the input. + // Adding a @[required] attribute will make decoding fail, if that field is not present in the input. // If a field is not [required], but is missing, it will be assumed to have its default value, like 0 for numbers, or '' for strings, and decoding will not fail. username string @[required] password string @[required] diff --git a/vlib/builtin/builtin_d_use_libbacktrace.c.v b/vlib/builtin/builtin_d_use_libbacktrace.c.v index 7e953c1953..2c6c3d200e 100644 --- a/vlib/builtin/builtin_d_use_libbacktrace.c.v +++ b/vlib/builtin/builtin_d_use_libbacktrace.c.v @@ -5,7 +5,7 @@ module builtin #flag @VEXEROOT/thirdparty/libbacktrace/backtrace.o #include -// NOTE: Don't mark this as a [typedef] or it may cause compiler errors! +// NOTE: Don't mark this as a @[typedef] or it may cause compiler errors! pub struct C.backtrace_state { // filename &char } diff --git a/vlib/builtin/string.v b/vlib/builtin/string.v index 3ef2cd6e63..36ba5b09e5 100644 --- a/vlib/builtin/string.v +++ b/vlib/builtin/string.v @@ -79,7 +79,7 @@ pub fn (s string) runes() []rune { // working with C style pointers to 0 terminated strings (i.e. `char*`). // It is recommended to use it, unless you *do* understand the implications of // tos/tos2/tos3/tos4/tos5 in terms of memory management and interactions with -// -autofree and `[manualfree]`. +// -autofree and `@[manualfree]`. // It will panic, if the pointer `s` is 0. @[unsafe] pub fn cstring_to_vstring(s &char) string { diff --git a/vlib/flag/flag.v b/vlib/flag/flag.v index 932a3817e1..7589f7d7d0 100644 --- a/vlib/flag/flag.v +++ b/vlib/flag/flag.v @@ -99,7 +99,7 @@ pub mut: // free frees the resources allocated for the given FlagParser instance. // It should be called manually in functions that use it, and that are -// marked with `[manualfree]`, otherwise, it is called automatically +// marked with `@[manualfree]`, otherwise, it is called automatically // in programs, compiled with `-autofree`. Note: you should NOT use the // instance over which you have called .free() for anything after the call. @[unsafe] diff --git a/vlib/orm/orm_test.v b/vlib/orm/orm_test.v index fc309389ed..52b9ae55dc 100644 --- a/vlib/orm/orm_test.v +++ b/vlib/orm/orm_test.v @@ -69,8 +69,8 @@ fn test_use_struct_field_as_limit() { assert users[0].age == 29 assert users[0].skipped_string == '' assert users[0].skipped_string2 == '' - assert users[0].skipped_array == [], 'skipped because of the [skip] tag, used for both sql and json' - assert users[0].skipped_array2 == [], "should be skipped, because of the sql specific [sql: '-'] tag" + assert users[0].skipped_array == [], 'skipped because of the @[skip] tag, used for both sql and json' + assert users[0].skipped_array2 == [], "should be skipped, because of the sql specific @[sql: '-'] tag" } fn test_orm() { diff --git a/vlib/regex/regex.v b/vlib/regex/regex.v index a858015230..a550ba5464 100644 --- a/vlib/regex/regex.v +++ b/vlib/regex/regex.v @@ -357,7 +357,7 @@ pub fn (mut re RE) reset() { } // reset for search mode fail -// gcc bug, dont use [inline] or go 5 time slower +// gcc bug, dont use @[inline] or go 5 time slower //[inline] @[direct_array_access] fn (mut re RE) reset_src() { diff --git a/vlib/toml/any.v b/vlib/toml/any.v index be88f0f0b6..41b9c93b51 100644 --- a/vlib/toml/any.v +++ b/vlib/toml/any.v @@ -332,7 +332,7 @@ pub fn (a Any) reflect[T]() T { mut toml_field_name := field.name // Remapping of field names, for example: // TOML: 'assert = "ok"' - // V: User { asrt string [toml: 'assert'] } + // V: User { asrt string @[toml: 'assert'] } // User.asrt == 'ok' for attr in field.attrs { if attr.starts_with('toml:') { diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index 520ac536e2..e490bb0061 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -366,7 +366,7 @@ pub: mod string name string is_pub bool - is_markused bool // an explicit `[markused]` tag; the const will NOT be removed by `-skip-unused`, no matter what + is_markused bool // an explicit `@[markused]` tag; the const will NOT be removed by `-skip-unused`, no matter what pos token.Pos attrs []Attr // same value as `attrs` of the ConstDecl to which it belongs pub mut: @@ -385,7 +385,7 @@ pub struct ConstDecl { pub: is_pub bool pos token.Pos - attrs []Attr // tags like `[markused]`, valid for all the consts in the list + attrs []Attr // tags like `@[markused]`, valid for all the consts in the list pub mut: fields []ConstField // all the const fields in the `const (...)` block end_comments []Comment // comments that after last const field @@ -544,16 +544,16 @@ pub: is_c_variadic bool is_variadic bool is_anon bool - is_noreturn bool // true, when [noreturn] is used on a fn - is_manualfree bool // true, when [manualfree] is used on a fn + is_noreturn bool // true, when @[noreturn] is used on a fn + is_manualfree bool // true, when @[manualfree] is used on a fn is_main bool // true for `fn main()` is_test bool // true for `fn test_abcde() {}`, false for `fn test_abc(x int) {}`, or for fns that do not start with test_ - is_conditional bool // true for `[if abc] fn abc(){}` + is_conditional bool // true for `@[if abc] fn abc(){}` is_exported bool // true for `@[export: 'exact_C_name']` is_keep_alive bool // passed memory must not be freed (by GC) before function returns - is_unsafe bool // true, when [unsafe] is used on a fn - is_markused bool // true, when an explicit `[markused]` tag was put on a fn; `-skip-unused` will not remove that fn - is_file_translated bool // true, when the file it resides in is `[translated]` + is_unsafe bool // true, when @[unsafe] is used on a fn + is_markused bool // true, when an explicit `@[markused]` tag was put on a fn; `-skip-unused` will not remove that fn + is_file_translated bool // true, when the file it resides in is `@[translated]` receiver StructField // TODO: this is not a struct field receiver_pos token.Pos // `(u User)` in `fn (u User) name()` position is_method bool @@ -634,10 +634,10 @@ pub: is_c_variadic bool language Language is_pub bool - is_ctor_new bool // `[use_new] fn JS.Array.prototype.constructor()` - is_deprecated bool // `[deprecated] fn abc(){}` - is_noreturn bool // `[noreturn] fn abc(){}` - is_unsafe bool // `[unsafe] fn abc(){}` + is_ctor_new bool // `@[use_new] fn JS.Array.prototype.constructor()` + is_deprecated bool // `@[deprecated] fn abc(){}` + is_noreturn bool // `@[noreturn] fn abc(){}` + is_unsafe bool // `@[unsafe] fn abc(){}` is_placeholder bool is_main bool // `fn main(){}` is_test bool // `fn test_abc(){}` @@ -645,7 +645,7 @@ pub: is_method bool // true for `fn (x T) name()`, and for interface declarations (which are also for methods) is_static_type_method bool // true for `fn Foo.bar() {}` no_body bool // a pure declaration like `fn abc(x int)`; used in .vh files, C./JS. fns. - is_file_translated bool // true, when the file it resides in is `[translated]` + is_file_translated bool // true, when the file it resides in is `@[translated]` mod string file string file_mode Language @@ -765,7 +765,7 @@ pub mut: is_keep_alive bool // GC must not free arguments before fn returns is_noreturn bool // whether the function/method is marked as [noreturn] is_ctor_new bool // if JS ctor calls requires `new` before call, marked as `[use_new]` in V - is_file_translated bool // true, when the file it resides in is `[translated]` + is_file_translated bool // true, when the file it resides in is `@[translated]` args []CallArg expected_arg_types []Type comptime_ret_val bool @@ -861,7 +861,7 @@ pub mut: is_or bool // `x := foo() or { ... }` is_tmp bool // for tmp for loop vars, so that autofree can skip them is_auto_heap bool // value whose address goes out of scope - is_stack_obj bool // may be pointer to stack value (`mut` or `&` arg and not [heap] struct) + is_stack_obj bool // may be pointer to stack value (`mut` or `&` arg and not @[heap] struct) } // used for smartcasting only @@ -902,7 +902,7 @@ pub: mod string pos token.Pos is_block bool // __global() block - attrs []Attr // tags like `[markused]`, valid for all the globals in the list + attrs []Attr // tags like `@[markused]`, valid for all the globals in the list pub mut: fields []GlobalField end_comments []Comment @@ -932,8 +932,8 @@ pub: mod Module // the module of the source file (from `module xyz` at the top) global_scope &Scope = unsafe { nil } is_test bool // true for _test.v files - is_generated bool // true for `[generated] module xyz` files; turn off notices - is_translated bool // true for `[translated] module xyz` files; turn off some checks + is_generated bool // true for `@[generated] module xyz` files; turn off notices + is_translated bool // true for `@[translated] module xyz` files; turn off some checks pub mut: idx int // index in an external container; can be used to refer to the file in a more efficient way, just by its integer index path string // absolute path of the source file - '/projects/v/file.v' @@ -1375,7 +1375,7 @@ pub struct EnumDecl { pub: name string is_pub bool - is_flag bool // true when the enum has [flag] tag,for bit field enum + is_flag bool // true when the enum has @[flag] tag,for bit field enum is_multi_allowed bool // true when the enum has [_allow_multiple_values] tag comments []Comment // comments before the first EnumField fields []EnumField // all the enum fields diff --git a/vlib/v/ast/attr.v b/vlib/v/ast/attr.v index 29573c658b..3a70f99881 100644 --- a/vlib/v/ast/attr.v +++ b/vlib/v/ast/attr.v @@ -13,7 +13,7 @@ pub enum AttrKind { comptime_define // [if name] } -// e.g. `[unsafe]` +// e.g. `@[unsafe]` @[minify] pub struct Attr { pub: diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 4acbf3ea1d..cd73522216 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -73,7 +73,7 @@ pub mut: scope_returns bool is_builtin_mod bool // true inside the 'builtin', 'os' or 'strconv' modules; TODO: remove the need for special casing this is_just_builtin_mod bool // true only inside 'builtin' - is_generated bool // true for `[generated] module xyz` .v files + is_generated bool // true for `@[generated] module xyz` .v files inside_unsafe bool // true inside `unsafe {}` blocks inside_const bool // true inside `const ( ... )` blocks inside_anon_fn bool // true inside `fn() { ... }()` @@ -465,7 +465,7 @@ fn (mut c Checker) file_has_main_fn(file &ast.File) bool { c.error('function `main` must declare a body', stmt.pos) } } else if stmt.attrs.contains('console') { - c.error('only `main` can have the `[console]` attribute', stmt.pos) + c.error('only `main` can have the `@[console]` attribute', stmt.pos) } } } @@ -1363,7 +1363,7 @@ fn (mut c Checker) check_or_last_stmt(mut stmt ast.Stmt, ret_type ast.Type, expr return } expected_type_name := c.table.type_to_str(ret_type.clear_option_and_result()) - c.error('`or` block must provide a default value of type `${expected_type_name}`, or return/continue/break or call a [noreturn] function like panic(err) or exit(1)', + c.error('`or` block must provide a default value of type `${expected_type_name}`, or return/continue/break or call a @[noreturn] function like panic(err) or exit(1)', stmt.expr.pos()) } else { if ret_type.is_ptr() && last_stmt_typ.is_pointer() @@ -1671,9 +1671,9 @@ fn (mut c Checker) selector_expr(mut node ast.SelectorExpr) ast.Type { rec_sym := c.table.sym(receiver.set_nr_muls(0)) if !rec_sym.is_heap() { suggestion := if rec_sym.kind == .struct_ { - 'declaring `${rec_sym.name}` as `[heap]`' + 'declaring `${rec_sym.name}` as `@[heap]`' } else { - 'wrapping the `${rec_sym.name}` object in a `struct` declared as `[heap]`' + 'wrapping the `${rec_sym.name}` object in a `struct` declared as `@[heap]`' } c.error('method `${c.table.type_to_str(receiver.idx())}.${method.name}` cannot be used as a variable outside `unsafe` blocks as its receiver might refer to an object stored on stack. Consider ${suggestion}.', node.expr.pos().extend(node.pos)) @@ -3905,7 +3905,7 @@ fn (mut c Checker) ident(mut node ast.Ident) ast.Type { c.error('undefined ident: `errcode`; did you mean `err.code`?', node.pos) } else { if c.inside_ct_attr { - c.note('`[if ${node.name}]` is deprecated. Use `[if ${node.name}?]` instead', + c.note('`[if ${node.name}]` is deprecated. Use `@[if ${node.name}?]` instead', node.pos) } else { cname_mod := node.name.all_before('.') @@ -4281,9 +4281,9 @@ fn (mut c Checker) mark_as_referenced(mut node ast.Expr, as_interface bool) { if obj.is_stack_obj && !type_sym.is_heap() && !c.pref.translated && !c.file.is_translated { suggestion := if type_sym.kind == .struct_ { - 'declaring `${type_sym.name}` as `[heap]`' + 'declaring `${type_sym.name}` as `@[heap]`' } else { - 'wrapping the `${type_sym.name}` object in a `struct` declared as `[heap]`' + 'wrapping the `${type_sym.name}` object in a `struct` declared as `@[heap]`' } mischief := if as_interface { 'used as interface object' } else { 'referenced' } c.error('`${node.name}` cannot be ${mischief} outside `unsafe` blocks as it might be stored on stack. Consider ${suggestion}.', @@ -4360,7 +4360,7 @@ fn (mut c Checker) prefix_expr(mut node ast.PrefixExpr) ast.Type { && (node.right.typ == ast.bool_type_idx || (right_sym.kind == .enum_ && !(right_sym.info as ast.Enum).is_flag && !(right_sym.info as ast.Enum).uses_exprs)) { - c.error('cannot take the address of field in struct `${c.table.type_to_str(node.right.expr_type)}`, which is tagged as `[minify]`', + c.error('cannot take the address of field in struct `${c.table.type_to_str(node.right.expr_type)}`, which is tagged as `@[minify]`', node.pos.extend(node.right.pos)) } diff --git a/vlib/v/checker/comptime.v b/vlib/v/checker/comptime.v index dd67308238..91a6b6453f 100644 --- a/vlib/v/checker/comptime.v +++ b/vlib/v/checker/comptime.v @@ -649,7 +649,7 @@ fn (mut c Checker) evaluate_once_comptime_if_attribute(mut node ast.Attr) bool { return node.ct_skip } else { if node.ct_expr.name !in ast.valid_comptime_not_user_defined { - c.note('`[if ${node.ct_expr.name}]` is deprecated. Use `[if ${node.ct_expr.name} ?]` instead', + c.note('`[if ${node.ct_expr.name}]` is deprecated. Use `@[if ${node.ct_expr.name} ?]` instead', node.pos) node.ct_skip = node.ct_expr.name !in c.pref.compile_defines node.ct_evaled = true diff --git a/vlib/v/checker/return.v b/vlib/v/checker/return.v index a4e5fb4453..ca35c83cd7 100644 --- a/vlib/v/checker/return.v +++ b/vlib/v/checker/return.v @@ -121,7 +121,7 @@ fn (mut c Checker) return_stmt(mut node ast.Return) { for expr in node.exprs { if expr is ast.Ident { if expr.name in pnames { - c.note('returning a parameter in a fn marked with `[manualfree]` can cause double freeing in the caller', + c.note('returning a parameter in a fn marked with `@[manualfree]` can cause double freeing in the caller', node.pos) } } @@ -308,7 +308,7 @@ fn (mut c Checker) find_unreachable_statements_after_noreturn_calls(stmts []ast. if stmt is ast.ExprStmt { if stmt.expr is ast.CallExpr { if prev_stmt_was_noreturn_call { - c.error('unreachable code after a [noreturn] call', stmt.pos) + c.error('unreachable code after a @[noreturn] call', stmt.pos) return } prev_stmt_was_noreturn_call = stmt.expr.is_noreturn @@ -388,7 +388,7 @@ fn (mut c Checker) check_noreturn_fn_decl(mut node ast.FnDecl) { else {} } if !is_valid_end_of_noreturn_fn { - c.error('[noreturn] functions should end with a call to another [noreturn] function, or with an infinite `for {}` loop', + c.error('@[noreturn] functions should end with a call to another @[noreturn] function, or with an infinite `for {}` loop', last_stmt.pos) return } diff --git a/vlib/v/checker/struct.v b/vlib/v/checker/struct.v index 8667b77d62..174b1c6780 100644 --- a/vlib/v/checker/struct.v +++ b/vlib/v/checker/struct.v @@ -96,7 +96,7 @@ fn (mut c Checker) struct_decl(mut node ast.StructDecl) { sym := c.table.sym(field.typ) if sym.kind == .function && !field.typ.has_flag(.option) && !field.has_default_expr && !field.attrs.contains('required') { - error_msg := 'uninitialized `fn` struct fields are not allowed, since they can result in segfaults; use `?fn` or `[required]` or initialize the field with `=` (if you absolutely want to have unsafe function pointers, use `= unsafe { nil }`)' + error_msg := 'uninitialized `fn` struct fields are not allowed, since they can result in segfaults; use `?fn` or `@[required]` or initialize the field with `=` (if you absolutely want to have unsafe function pointers, use `= unsafe { nil }`)' c.note(error_msg, field.pos) } } @@ -855,7 +855,7 @@ or use an explicit `unsafe{ a[..] }`, if you do not want a copy of the slice.', node.pos) } */ - // Check for `[required]` struct attr + // Check for `@[required]` struct attr if !node.no_keys && !node.has_update_expr && field.attrs.contains('required') && node.init_fields.all(it.name != field.name) { c.error('field `${type_sym.name}.${field.name}` must be initialized', diff --git a/vlib/v/checker/tests/fn_check_for_matching_option_result_in_fields.out b/vlib/v/checker/tests/fn_check_for_matching_option_result_in_fields.out index 0269535350..4672899517 100644 --- a/vlib/v/checker/tests/fn_check_for_matching_option_result_in_fields.out +++ b/vlib/v/checker/tests/fn_check_for_matching_option_result_in_fields.out @@ -1,4 +1,4 @@ -vlib/v/checker/tests/fn_check_for_matching_option_result_in_fields.vv:2:2: notice: uninitialized `fn` struct fields are not allowed, since they can result in segfaults; use `?fn` or `[required]` or initialize the field with `=` (if you absolutely want to have unsafe function pointers, use `= unsafe { nil }`) +vlib/v/checker/tests/fn_check_for_matching_option_result_in_fields.vv:2:2: notice: uninitialized `fn` struct fields are not allowed, since they can result in segfaults; use `?fn` or `@[required]` or initialize the field with `=` (if you absolutely want to have unsafe function pointers, use `= unsafe { nil }`) 1 | struct Abc { 2 | f fn (voidptr) | ~~~~~~~~~~~~~~ diff --git a/vlib/v/checker/tests/generics_struct_init_err.out b/vlib/v/checker/tests/generics_struct_init_err.out index a729f888c4..6d0723a0da 100644 --- a/vlib/v/checker/tests/generics_struct_init_err.out +++ b/vlib/v/checker/tests/generics_struct_init_err.out @@ -1,4 +1,4 @@ -vlib/v/checker/tests/generics_struct_init_err.vv:14:2: notice: uninitialized `fn` struct fields are not allowed, since they can result in segfaults; use `?fn` or `[required]` or initialize the field with `=` (if you absolutely want to have unsafe function pointers, use `= unsafe { nil }`) +vlib/v/checker/tests/generics_struct_init_err.vv:14:2: notice: uninitialized `fn` struct fields are not allowed, since they can result in segfaults; use `?fn` or `@[required]` or initialize the field with `=` (if you absolutely want to have unsafe function pointers, use `= unsafe { nil }`) 12 | 13 | struct FnHolder2[T] { 14 | func fn (int) int diff --git a/vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.out b/vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.out index 02fbccc825..882b9ed333 100644 --- a/vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.out +++ b/vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.out @@ -1,11 +1,11 @@ -vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv:4:6: error: [noreturn] functions should end with a call to another [noreturn] function, or with an infinite `for {}` loop +vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv:4:6: error: @[noreturn] functions should end with a call to another @[noreturn] function, or with an infinite `for {}` loop 2 | fn another() { 3 | eprintln(@FN) 4 | for { | ^ 5 | break 6 | } -vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv:18:2: error: unreachable code after a [noreturn] call +vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv:18:2: error: unreachable code after a @[noreturn] call 16 | eprintln('start') 17 | abc() 18 | eprintln('done') diff --git a/vlib/v/checker/tests/noreturn_with_return.out b/vlib/v/checker/tests/noreturn_with_return.out index c482f05d50..0164afc38f 100644 --- a/vlib/v/checker/tests/noreturn_with_return.out +++ b/vlib/v/checker/tests/noreturn_with_return.out @@ -4,14 +4,14 @@ vlib/v/checker/tests/noreturn_with_return.vv:2:1: error: [noreturn] functions ca | ~~~~~~~~~~~~ 3 | eprintln(@FN) 4 | // for{} -vlib/v/checker/tests/noreturn_with_return.vv:6:2: error: [noreturn] functions should end with a call to another [noreturn] function, or with an infinite `for {}` loop +vlib/v/checker/tests/noreturn_with_return.vv:6:2: error: @[noreturn] functions should end with a call to another @[noreturn] function, or with an infinite `for {}` loop 4 | // for{} 5 | // exit(0) 6 | return | ~~~~~~ 7 | } 8 | -vlib/v/checker/tests/noreturn_with_return.vv:18:2: error: unreachable code after a [noreturn] call +vlib/v/checker/tests/noreturn_with_return.vv:18:2: error: unreachable code after a @[noreturn] call 16 | eprintln('start') 17 | abc() 18 | eprintln('done') diff --git a/vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.out b/vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.out index c8a033c87f..ec14b5e792 100644 --- a/vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.out +++ b/vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.out @@ -1,11 +1,11 @@ -vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv:3:2: error: [noreturn] functions should end with a call to another [noreturn] function, or with an infinite `for {}` loop +vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv:3:2: error: @[noreturn] functions should end with a call to another @[noreturn] function, or with an infinite `for {}` loop 1 | @[noreturn] 2 | fn another() { 3 | eprintln(@FN) | ~~~~~~~~~~~~~ 4 | } 5 | -vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv:15:2: error: unreachable code after a [noreturn] call +vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv:15:2: error: unreachable code after a @[noreturn] call 13 | eprintln('start') 14 | abc() 15 | eprintln('done') diff --git a/vlib/v/checker/tests/or_block_check_err.out b/vlib/v/checker/tests/or_block_check_err.out index 27c763d536..c4fb27bba8 100644 --- a/vlib/v/checker/tests/or_block_check_err.out +++ b/vlib/v/checker/tests/or_block_check_err.out @@ -12,14 +12,14 @@ vlib/v/checker/tests/or_block_check_err.vv:7:37: error: assignment requires a no | ~~~~~ 8 | 9 | _ = callexpr_with_or_block_call() or { eprintln('error') }.replace('a', 'b') -vlib/v/checker/tests/or_block_check_err.vv:9:41: error: `or` block must provide a default value of type `string`, or return/continue/break or call a [noreturn] function like panic(err) or exit(1) +vlib/v/checker/tests/or_block_check_err.vv:9:41: error: `or` block must provide a default value of type `string`, or return/continue/break or call a @[noreturn] function like panic(err) or exit(1) 7 | _ = (callexpr_with_or_block_call() or {}).replace('a', 'b') 8 | 9 | _ = callexpr_with_or_block_call() or { eprintln('error') }.replace('a', 'b') | ~~~~~~~~~~~~~~~~~ 10 | _ = (callexpr_with_or_block_call() or { eprintln('error') }).replace('a', 'b') 11 | } -vlib/v/checker/tests/or_block_check_err.vv:10:42: error: `or` block must provide a default value of type `string`, or return/continue/break or call a [noreturn] function like panic(err) or exit(1) +vlib/v/checker/tests/or_block_check_err.vv:10:42: error: `or` block must provide a default value of type `string`, or return/continue/break or call a @[noreturn] function like panic(err) or exit(1) 8 | 9 | _ = callexpr_with_or_block_call() or { eprintln('error') }.replace('a', 'b') 10 | _ = (callexpr_with_or_block_call() or { eprintln('error') }).replace('a', 'b') diff --git a/vlib/v/checker/tests/static_vars_in_translated_mode.out b/vlib/v/checker/tests/static_vars_in_translated_mode.out index 966a2d75fb..0ad137ff4d 100644 --- a/vlib/v/checker/tests/static_vars_in_translated_mode.out +++ b/vlib/v/checker/tests/static_vars_in_translated_mode.out @@ -1,4 +1,4 @@ -vlib/v/checker/tests/static_vars_in_translated_mode.vv:2:13: error: static variables are supported only in translated mode or in [unsafe] fn +vlib/v/checker/tests/static_vars_in_translated_mode.vv:2:13: error: static variables are supported only in translated mode or in @[unsafe] fn 1 | fn counter() int { 2 | mut static icounter := 0 | ~~~~~~~~ diff --git a/vlib/v/checker/tests/unsafe_method_as_field.out b/vlib/v/checker/tests/unsafe_method_as_field.out index 7a99846384..bad477e9f3 100644 --- a/vlib/v/checker/tests/unsafe_method_as_field.out +++ b/vlib/v/checker/tests/unsafe_method_as_field.out @@ -1,7 +1,7 @@ -vlib/v/checker/tests/unsafe_method_as_field.vv:23:7: error: method `Foo.ref` cannot be used as a variable outside `unsafe` blocks as its receiver might refer to an object stored on stack. Consider declaring `Foo` as `[heap]`. +vlib/v/checker/tests/unsafe_method_as_field.vv:23:7: error: method `Foo.ref` cannot be used as a variable outside `unsafe` blocks as its receiver might refer to an object stored on stack. Consider declaring `Foo` as `@[heap]`. 21 | f := Foo{} 22 | _ := f.no_ref // no error 23 | _ := f.ref // error | ~~~~~ - 24 | - 25 | b := Bar{} \ No newline at end of file + 24 | + 25 | b := Bar{} diff --git a/vlib/v/checker/tests/var_option_wrong_type.out b/vlib/v/checker/tests/var_option_wrong_type.out index 532bdf75a9..cf4792a506 100644 --- a/vlib/v/checker/tests/var_option_wrong_type.out +++ b/vlib/v/checker/tests/var_option_wrong_type.out @@ -10,7 +10,7 @@ vlib/v/checker/tests/var_option_wrong_type.vv:3:23: error: infix expr: cannot us 3 | var3 := var_none or { var_none + 'foo' } | ~~~~~~~~~~~~~~~~ 4 | println(var3) -vlib/v/checker/tests/var_option_wrong_type.vv:3:23: error: `or` block must provide a default value of type `f64`, or return/continue/break or call a [noreturn] function like panic(err) or exit(1) +vlib/v/checker/tests/var_option_wrong_type.vv:3:23: error: `or` block must provide a default value of type `f64`, or return/continue/break or call a @[noreturn] function like panic(err) or exit(1) 1 | var_none := ?f64(none) 2 | 3 | var3 := var_none or { var_none + 'foo' } diff --git a/vlib/v/gen/c/auto_str_methods.v b/vlib/v/gen/c/auto_str_methods.v index 208d4e39e6..44c0e2129e 100644 --- a/vlib/v/gen/c/auto_str_methods.v +++ b/vlib/v/gen/c/auto_str_methods.v @@ -342,7 +342,7 @@ fn (mut g Gen) gen_str_for_enum(info ast.Enum, styp string, str_fn_name string) s := util.no_dots(styp) g.definitions.writeln('static string ${str_fn_name}(${styp} it); // auto') g.auto_str_funcs.writeln('static string ${str_fn_name}(${styp} it) { /* gen_str_for_enum */') - // Enums tagged with `[flag]` are special in that they can be a combination of enum values + // Enums tagged with `@[flag]` are special in that they can be a combination of enum values if info.is_flag { clean_name := util.strip_main_name(styp.replace('__', '.')) g.auto_str_funcs.writeln('\tstring ret = _SLIT("${clean_name}{");') diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 1094136b18..2ed0768246 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -225,7 +225,7 @@ mut: curr_var_name []string // curr var name on assignment called_fn_name string timers &util.Timers = util.get_timers() - force_main_console bool // true when [console] used on fn main() + force_main_console bool // true when @[console] used on fn main() as_cast_type_names map[string]string // table for type name lookup in runtime (for __as_cast) obf_table map[string]string referenced_fns shared map[string]bool // functions that have been referenced diff --git a/vlib/v/gen/c/fn.v b/vlib/v/gen/c/fn.v index a579375b11..d42cf6295c 100644 --- a/vlib/v/gen/c/fn.v +++ b/vlib/v/gen/c/fn.v @@ -221,7 +221,7 @@ fn (mut g Gen) gen_fn_decl(node &ast.FnDecl, skip bool) { is_livemode := g.pref.is_livemain || g.pref.is_liveshared is_live_wrap := is_livefn && is_livemode if is_livefn && !is_livemode { - eprintln('INFO: compile with `v -live ${g.pref.path} `, if you want to use the [live] function ${node.name} .') + eprintln('INFO: compile with `v -live ${g.pref.path} `, if you want to use the @[live] function ${node.name} .') } mut name := g.c_fn_name(node) @@ -553,7 +553,7 @@ fn (mut g Gen) c_fn_name(node &ast.FnDecl) string { if cattr := node.attrs.find_first('c') { // This fixes unknown symbols errors when building separate .c => .v files into .o files // example: - // [c: 'P_TryMove'] fn p_trymove(thing &Mobj_t, x int, y int) bool + // @[c: 'P_TryMove'] fn p_trymove(thing &Mobj_t, x int, y int) bool // translates to: // bool P_TryMove(main__Mobj_t* thing, int x, int y); // In fn_call every time `p_trymove` is called, `P_TryMove` will be generated instead. @@ -1962,7 +1962,7 @@ fn (mut g Gen) fn_call(node ast.CallExpr) { name = c_fn_name(name) } if g.pref.translated || g.file.is_translated || node.is_file_translated { - // For `[c: 'P_TryMove'] fn p_trymove( ... ` + // For `@[c: 'P_TryMove'] fn p_trymove( ... ` // every time `p_trymove` is called, `P_TryMove` must be generated instead. if f := g.table.find_fn(node.name) { // TODO: PERF fn lookup for each fn call in translated mode @@ -2764,22 +2764,22 @@ fn (mut g Gen) write_fn_attrs(attrs []ast.Attr) string { // only the exported wrapper should be weak; otherwise x86_64-w64-mingw32-gcc complains continue } - // a `[weak]` tag tells the C compiler, that the next declaration will be weak, i.e. when linking, + // a `@[weak]` tag tells the C compiler, that the next declaration will be weak, i.e. when linking, // if there is another declaration of a symbol with the same name (a 'strong' one), it should be // used instead, *without linker errors about duplicate symbols*. g.write('VWEAK ') } 'noreturn' { - // a `[noreturn]` tag tells the compiler, that a function + // a `@[noreturn]` tag tells the compiler, that a function // *DOES NOT RETURN* to its callsites. // See: https://en.cppreference.com/w/c/language/_Noreturn // Such functions should have no return type. They can be used // in places where `panic(err)` or `exit(0)` can be used. // panic/1 and exit/0 themselves will also be marked as - // `[noreturn]` soon. + // `@[noreturn]` soon. // These functions should have busy `for{}` loops injected // at their end, when they do not end by calling other fns - // marked by `[noreturn]`. + // marked by `@[noreturn]`. g.write('VNORETURN ') } 'irq_handler' { diff --git a/vlib/v/gen/c/live.v b/vlib/v/gen/c/live.v index f5f2054749..570dfc6e06 100644 --- a/vlib/v/gen/c/live.v +++ b/vlib/v/gen/c/live.v @@ -103,7 +103,7 @@ fn (mut g Gen) generate_hotcode_reloading_main_caller() { mut idx := 0 for f, _ in already_added { fpath := os.real_path(f) - g.writeln('\t\tv__live__executable__add_live_monitored_file(live_info, ${ctoslit(fpath)}); // source V file with [live] ${ + g.writeln('\t\tv__live__executable__add_live_monitored_file(live_info, ${ctoslit(fpath)}); // source V file with @[live] ${ idx + 1}/${already_added.len}') idx++ } diff --git a/vlib/v/gen/js/auto_str_methods.v b/vlib/v/gen/js/auto_str_methods.v index 9c293d0bbf..01440da458 100644 --- a/vlib/v/gen/js/auto_str_methods.v +++ b/vlib/v/gen/js/auto_str_methods.v @@ -303,7 +303,7 @@ fn (mut g JsGen) gen_str_for_enum(info ast.Enum, styp string, str_fn_name string s := util.no_dots(styp) g.definitions.writeln('function ${str_fn_name}(it) { /* gen_str_for_enum */') - // Enums tagged with `[flag]` are special in that they can be a combination of enum values + // Enums tagged with `@[flag]` are special in that they can be a combination of enum values if info.is_flag { clean_name := util.strip_main_name(styp.replace('__', '.')) g.definitions.writeln('\tlet ret = new string("${clean_name}{");') diff --git a/vlib/v/gen/js/fn.v b/vlib/v/gen/js/fn.v index 9a75b14083..30b52768d8 100644 --- a/vlib/v/gen/js/fn.v +++ b/vlib/v/gen/js/fn.v @@ -638,7 +638,7 @@ fn (mut g JsGen) gen_method_decl(it ast.FnDecl, typ FnGenType) { for attr in it.attrs { if attr.name == 'async' { if g.pref.output_es5 { - verror('cannot use [async] attribute when outputting ES5 source code') + verror('cannot use @[async] attribute when outputting ES5 source code') } has_go = true break diff --git a/vlib/v/live/common.c.v b/vlib/v/live/common.c.v index adffe7a244..edd63f2dcb 100644 --- a/vlib/v/live/common.c.v +++ b/vlib/v/live/common.c.v @@ -9,7 +9,7 @@ pub: vexe string // full path to the v compiler vopts string // v compiler options for a live shared library original string // full path to the original source file, compiled with -live - live_fn_mutex voidptr // the address of the C mutex, that locks the [live] fns during reloads. + live_fn_mutex voidptr // the address of the C mutex, that locks the @[live] fns during reloads. live_linkfn FNLinkLiveSymbols = unsafe { nil } // generated C callback; receives a dlopen handle so_extension string // .so or .dll so_name_template string // a template for the shared libraries location @@ -38,7 +38,7 @@ pub mut: // The callbacks: cb_compile_fail, cb_before, cb_after will be // executed outside the mutex protected section, so be careful, // if you modify your data inside them. They can race with your -// [live] functions. +// @[live] functions. // // cb_locked_before and cb_locked_after will be executed *inside* // the mutex protected section. They can NOT race with your [live] diff --git a/vlib/v/live/executable/reloader.c.v b/vlib/v/live/executable/reloader.c.v index 79104abeb0..210498b106 100644 --- a/vlib/v/live/executable/reloader.c.v +++ b/vlib/v/live/executable/reloader.c.v @@ -48,7 +48,7 @@ pub fn start_reloader(mut r live.LiveReloadInfo) { // add_live_monitored_file will be called by the generated code inside main(), to add a list of all the .v files // that were used during the main program compilation. Any change to any of them, will later trigger a -// recompilation and reloading of the produced shared library. This makes it possible for [live] functions +// recompilation and reloading of the produced shared library. This makes it possible for @[live] functions // inside modules to also work, not just in the top level program. @[markused] pub fn add_live_monitored_file(mut lri live.LiveReloadInfo, path string) { diff --git a/vlib/v/live/live_test.v b/vlib/v/live/live_test.v index 44dcc2f260..5ab1c2156c 100644 --- a/vlib/v/live/live_test.v +++ b/vlib/v/live/live_test.v @@ -7,7 +7,7 @@ import time /* The goal of this test, is to simulate a developer, that has run a program, compiled with -live flag. -It does so by writing a new generated program containing a [live] fn pmessage() string {...} function, +It does so by writing a new generated program containing a @[live] fn pmessage() string {...} function, (that program is in `vlib/v/live/live_test_template.vv`) then runs the generated program at the start *in the background*, waits some time, so that the program could run a few iterations, then modifies its source diff --git a/vlib/v/markused/markused.v b/vlib/v/markused/markused.v index c7baa6b7f4..b409a0060e 100644 --- a/vlib/v/markused/markused.v +++ b/vlib/v/markused/markused.v @@ -334,9 +334,9 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a pref: pref_ } // println( all_fns.keys() ) - walker.mark_markused_fns() // tagged with `[markused]` - walker.mark_markused_consts() // tagged with `[markused]` - walker.mark_markused_globals() // tagged with `[markused]` + walker.mark_markused_fns() // tagged with `@[markused]` + walker.mark_markused_consts() // tagged with `@[markused]` + walker.mark_markused_globals() // tagged with `@[markused]` walker.mark_exported_fns() walker.mark_root_fns(all_fn_root_names) diff --git a/vlib/v/parser/assign.v b/vlib/v/parser/assign.v index 81c747cbef..cea4a797fe 100644 --- a/vlib/v/parser/assign.v +++ b/vlib/v/parser/assign.v @@ -209,7 +209,7 @@ fn (mut p Parser) partial_assign_stmt(left []ast.Expr) ast.Stmt { if lx.info.is_static { if !p.pref.translated && !p.is_translated && !p.pref.is_fmt && !p.inside_unsafe_fn { - return p.error_with_pos('static variables are supported only in translated mode or in [unsafe] fn', + return p.error_with_pos('static variables are supported only in translated mode or in @[unsafe] fn', lx.pos) } is_static = true diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 6f8e2d3342..d24e8ccbc8 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -75,10 +75,10 @@ mut: or_is_handled bool // ignore `or` in this expression builtin_mod bool // are we in the `builtin` module? mod string // current module name - is_manualfree bool // true when `[manualfree] module abc`, makes *all* fns in the current .v file, opt out of autofree - has_globals bool // `[has_globals] module abc` - allow globals declarations, even without -enable-globals, in that single .v file __only__ - is_generated bool // `[generated] module abc` - turn off compiler notices for that single .v file __only__. - is_translated bool // `[translated] module abc` - mark a file as translated, to relax some compiler checks for translated code. + is_manualfree bool // true when `@[manualfree] module abc`, makes *all* fns in the current .v file, opt out of autofree + has_globals bool // `@[has_globals] module abc` - allow globals declarations, even without -enable-globals, in that single .v file __only__ + is_generated bool // `@[generated] module abc` - turn off compiler notices for that single .v file __only__. + is_translated bool // `@[translated] module abc` - mark a file as translated, to relax some compiler checks for translated code. attrs []ast.Attr // attributes before next decl stmt expr_mod string // for constructing full type names in parse_type() imports map[string]string // alias => mod_name diff --git a/vlib/v/parser/tests/or_default_missing.out b/vlib/v/parser/tests/or_default_missing.out index 00cb8c5396..7ceef029ef 100644 --- a/vlib/v/parser/tests/or_default_missing.out +++ b/vlib/v/parser/tests/or_default_missing.out @@ -1,4 +1,4 @@ -vlib/v/parser/tests/or_default_missing.vv:4:3: error: `or` block must provide a default value of type `int`, or return/continue/break or call a [noreturn] function like panic(err) or exit(1) +vlib/v/parser/tests/or_default_missing.vv:4:3: error: `or` block must provide a default value of type `int`, or return/continue/break or call a @[noreturn] function like panic(err) or exit(1) 2 | m := [3, 4, 5] 3 | el := m[4] or { 4 | println('error') diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index 1393a214e8..f13c5be1ce 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -122,7 +122,7 @@ pub mut: test_runner string // can be 'simple' (fastest, but much less detailed), 'tap', 'normal' profile_file string // the profile results will be stored inside profile_file coverage_dir string // the coverage files will be stored inside coverage_dir - profile_no_inline bool // when true, [inline] functions would not be profiled + profile_no_inline bool // when true, @[inline] functions would not be profiled profile_fns []string // when set, profiling will be off by default, but inside these functions (and what they call) it will be on. translated bool // `v translate doom.v` are we running V code translated from C? allow globals, ++ expressions, etc obfuscate bool // `v -obf program.v`, renames functions to "f_XXX" diff --git a/vlib/v/slow_tests/valgrind/1.strings_and_arrays.v b/vlib/v/slow_tests/valgrind/1.strings_and_arrays.v index fd1d10b1e4..a91160d1c0 100644 --- a/vlib/v/slow_tests/valgrind/1.strings_and_arrays.v +++ b/vlib/v/slow_tests/valgrind/1.strings_and_arrays.v @@ -374,7 +374,7 @@ fn parse_header1(s string) !string { return words[0] } -// TODO: remove this [manualfree] tag +// TODO: remove this @[manualfree] tag @[manualfree] fn advanced_options() { s := parse_header0('foo:bar') or { return } diff --git a/vlib/v/tests/project_with_c_code_2/modc/wrapper.c.v b/vlib/v/tests/project_with_c_code_2/modc/wrapper.c.v index 9f661031b8..c9a3cd509d 100644 --- a/vlib/v/tests/project_with_c_code_2/modc/wrapper.c.v +++ b/vlib/v/tests/project_with_c_code_2/modc/wrapper.c.v @@ -7,7 +7,7 @@ module modc pub struct C.Atype { } -// Note: [trusted] below, means that the C function, can be safely called outside unsafe{} blocks. +// Note: @[trusted] below, means that the C function, can be safely called outside unsafe{} blocks. // // By default, all C. functions are NOT trusted, and all V functions are by default trusted. // @@ -25,7 +25,7 @@ fn C.new_atype(int) voidptr fn C.handle_array(voidptr, int) fn todo_remove_me() { - // TODO: remove this dummy function, when the vfmt bug of [trusted] after a void C function is fixed + // TODO: remove this dummy function, when the vfmt bug of @[trusted] after a void C function is fixed } @[trusted] diff --git a/vlib/v/tests/ref_struct_test.v b/vlib/v/tests/ref_struct_test.v index 4218e637e2..f244306196 100644 --- a/vlib/v/tests/ref_struct_test.v +++ b/vlib/v/tests/ref_struct_test.v @@ -64,7 +64,7 @@ fn test_ref_field() { assert y.a.n == 29 } -// Yxc should become [heap] implicitly because `Abc` is +// Yxc should become @[heap] implicitly because `Abc` is struct Yxc { mut: diff --git a/vlib/v/tests/unsafe_test.c.v b/vlib/v/tests/unsafe_test.c.v index 95277b073f..e133aae91a 100644 --- a/vlib/v/tests/unsafe_test.c.v +++ b/vlib/v/tests/unsafe_test.c.v @@ -49,7 +49,7 @@ fn (s S1) f() { fn test_funcs() { s := S1{} unsafe { s.f() } - _ = C.strerror(0) // [trusted] function prototype in builtin/cfns.c.v + _ = C.strerror(0) // @[trusted] function prototype in builtin/cfns.c.v } fn test_if_expr_unsafe() { diff --git a/vlib/v/util/surrounder.v b/vlib/v/util/surrounder.v index c1b135cb93..2e77d59fb2 100644 --- a/vlib/v/util/surrounder.v +++ b/vlib/v/util/surrounder.v @@ -128,7 +128,7 @@ pub fn (s &Surrounder) builder_write_afters(mut sb strings.Builder) { } // free frees the private resources associated with the surrounder instance -// Called automatically by `-autofree`, or in `[manualfree]` tagged functions. +// Called automatically by `-autofree`, or in `@[manualfree]` tagged functions. @[unsafe] pub fn (mut s Surrounder) free() { unsafe { diff --git a/vlib/x/json2/tests/json_module_compatibility_test/json_test.v b/vlib/x/json2/tests/json_module_compatibility_test/json_test.v index f173187103..a4f389e1b5 100644 --- a/vlib/x/json2/tests/json_module_compatibility_test/json_test.v +++ b/vlib/x/json2/tests/json_module_compatibility_test/json_test.v @@ -51,7 +51,7 @@ fn test_simple() { // struct Price { // net f64 -// currency_id string [json: currencyId] = currency_id +// currency_id string @[json: currencyId] = currency_id // } struct User2 {