parser: improve the error for keyword lock, used as a variable name (#21937)

This commit is contained in:
Swastik Baranwal 2024-07-27 13:37:25 +05:30 committed by GitHub
parent 52fe7c09b8
commit 0ef2501216
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 1 deletions

View File

@ -72,7 +72,7 @@ fn (mut p Parser) lock_expr() ast.LockExpr {
for {
is_rlock := p.tok.kind == .key_rlock
if !is_rlock && p.tok.kind != .key_lock {
p.unexpected(expecting: '`lock` or `rlock`')
p.unexpected(expecting: 'one or more shared variable names')
}
p.next()
if p.tok.kind == .lcbr {

View File

@ -0,0 +1,3 @@
vlib/v/parser/tests/lock_var_name_assign_err.vv:1:6: error: unexpected token `:=`, expecting one or more shared variable names
1 | lock := 12
| ~~

View File

@ -0,0 +1 @@
lock := 12