checker: fix message with old attr syntax (#23529)

This commit is contained in:
Felipe Pena 2025-01-20 05:36:09 -03:00 committed by GitHub
parent 6d40bb8374
commit bd10e12460
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 7 deletions

View File

@ -668,7 +668,7 @@ fn (mut c Checker) evaluate_once_comptime_if_attribute(mut node ast.Attr) bool {
if mut node.ct_expr is ast.Ident {
if node.ct_opt {
if node.ct_expr.name in ast.valid_comptime_not_user_defined {
c.error('option `[if expression ?]` tags, can be used only for user defined identifiers',
c.error('option `@[if expression ?]` tags, can be used only for user defined identifiers',
node.pos)
node.ct_skip = true
} else {
@ -678,7 +678,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

View File

@ -138,7 +138,7 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) {
}
if ct_attr_idx := node.attrs.find_comptime_define() {
sexpr := node.attrs[ct_attr_idx].ct_expr.str()
c.error('only functions that do NOT return values can have `[if ${sexpr}]` tags',
c.error('only functions that do NOT return values can have `@[if ${sexpr}]` tags',
node.pos)
}
if node.generic_names.len > 0 {

View File

@ -392,7 +392,7 @@ fn (mut c Checker) check_noreturn_fn_decl(mut node ast.FnDecl) {
ast.ExprStmt {
if last_stmt.expr is ast.CallExpr {
if last_stmt.expr.should_be_skipped {
c.error('[noreturn] functions cannot end with a skippable `[if ..]` call',
c.error('@[noreturn] functions cannot end with a skippable `@[if ..]` call',
last_stmt.pos)
return
}

View File

@ -1,5 +1,5 @@
vlib/v/checker/tests/ctdefine.vv:4:1: error: only functions that do NOT return values can have `[if test]` tags
2 |
vlib/v/checker/tests/ctdefine.vv:4:1: error: only functions that do NOT return values can have `@[if test]` tags
2 |
3 | @[if test]
4 | fn only_called_in_test() string {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -8,5 +8,5 @@ vlib/v/checker/tests/ctdefine.vv:4:1: error: only functions that do NOT return v
vlib/v/checker/tests/ctdefine.vv:1:1: error: project must include a `main` module or be a shared library (compile with `v -shared`)
1 | module notmain
| ^
2 |
2 |
3 | @[if test]