Skip to content

Commit

Permalink
checker: fix message with old attr syntax (#23529)
Browse files Browse the repository at this point in the history
felipensp authored Jan 20, 2025

Partially verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
1 parent 6d40bb8 commit bd10e12
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions vlib/v/checker/comptime.v
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion vlib/v/checker/fn.v
Original file line number Diff line number Diff line change
@@ -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 {
2 changes: 1 addition & 1 deletion vlib/v/checker/return.v
Original file line number Diff line number Diff line change
@@ -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
}
6 changes: 3 additions & 3 deletions vlib/v/checker/tests/ctdefine.out
Original file line number Diff line number Diff line change
@@ -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]

0 comments on commit bd10e12

Please sign in to comment.