mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix wrong nodes generated for $something (#17969)
This commit is contained in:
parent
6e0204a614
commit
8e959ae5b5
5
vlib/v/checker/tests/invalid_comptime_test.out
Normal file
5
vlib/v/checker/tests/invalid_comptime_test.out
Normal file
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/invalid_comptime_test.vv:1:1: error: unexpected token `$`
|
||||
1 | $fn func(a int) int {
|
||||
| ^
|
||||
2 | return a + a
|
||||
3 | }
|
7
vlib/v/checker/tests/invalid_comptime_test.vv
Normal file
7
vlib/v/checker/tests/invalid_comptime_test.vv
Normal file
@ -0,0 +1,7 @@
|
||||
$fn func(a int) int {
|
||||
return a + a
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println(func(5))
|
||||
}
|
@ -754,7 +754,7 @@ pub fn (mut p Parser) top_stmt() ast.Stmt {
|
||||
if p.peek_tok.kind == .key_for {
|
||||
comptime_for_stmt := p.comptime_for()
|
||||
return p.other_stmts(comptime_for_stmt)
|
||||
} else {
|
||||
} else if p.peek_tok.kind == .key_if {
|
||||
if_expr := p.if_expr(true)
|
||||
cur_stmt := ast.ExprStmt{
|
||||
expr: if_expr
|
||||
@ -765,6 +765,8 @@ pub fn (mut p Parser) top_stmt() ast.Stmt {
|
||||
} else {
|
||||
return p.other_stmts(cur_stmt)
|
||||
}
|
||||
} else {
|
||||
return p.unexpected()
|
||||
}
|
||||
}
|
||||
.hash {
|
||||
|
Loading…
x
Reference in New Issue
Block a user