mirror of
https://github.com/vlang/v.git
synced 2025-09-10 16:00:31 -04:00
checker: fix message with old attr syntax (#23529)
This commit is contained in:
parent
6d40bb8374
commit
bd10e12460
@ -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 mut node.ct_expr is ast.Ident {
|
||||||
if node.ct_opt {
|
if node.ct_opt {
|
||||||
if node.ct_expr.name in ast.valid_comptime_not_user_defined {
|
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.pos)
|
||||||
node.ct_skip = true
|
node.ct_skip = true
|
||||||
} else {
|
} else {
|
||||||
@ -678,7 +678,7 @@ fn (mut c Checker) evaluate_once_comptime_if_attribute(mut node ast.Attr) bool {
|
|||||||
return node.ct_skip
|
return node.ct_skip
|
||||||
} else {
|
} else {
|
||||||
if node.ct_expr.name !in ast.valid_comptime_not_user_defined {
|
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.pos)
|
||||||
node.ct_skip = node.ct_expr.name !in c.pref.compile_defines
|
node.ct_skip = node.ct_expr.name !in c.pref.compile_defines
|
||||||
node.ct_evaled = true
|
node.ct_evaled = true
|
||||||
|
@ -138,7 +138,7 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) {
|
|||||||
}
|
}
|
||||||
if ct_attr_idx := node.attrs.find_comptime_define() {
|
if ct_attr_idx := node.attrs.find_comptime_define() {
|
||||||
sexpr := node.attrs[ct_attr_idx].ct_expr.str()
|
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)
|
node.pos)
|
||||||
}
|
}
|
||||||
if node.generic_names.len > 0 {
|
if node.generic_names.len > 0 {
|
||||||
|
@ -392,7 +392,7 @@ fn (mut c Checker) check_noreturn_fn_decl(mut node ast.FnDecl) {
|
|||||||
ast.ExprStmt {
|
ast.ExprStmt {
|
||||||
if last_stmt.expr is ast.CallExpr {
|
if last_stmt.expr is ast.CallExpr {
|
||||||
if last_stmt.expr.should_be_skipped {
|
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)
|
last_stmt.pos)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
vlib/v/checker/tests/ctdefine.vv:4:1: error: only functions that do NOT return values can have `[if test]` tags
|
vlib/v/checker/tests/ctdefine.vv:4:1: error: only functions that do NOT return values can have `@[if test]` tags
|
||||||
2 |
|
2 |
|
||||||
3 | @[if test]
|
3 | @[if test]
|
||||||
4 | fn only_called_in_test() string {
|
4 | fn only_called_in_test() string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user