Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checker: fix message with old attr syntax #23529

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions vlib/v/checker/comptime.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/checker/fn.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/checker/return.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
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 {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -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]
Loading