1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: fix expected type enum error pos (#7265)

This commit is contained in:
Daniel Däschle 2020-12-11 18:23:29 +01:00 committed by GitHub
parent 25153490e1
commit 597c2249e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -1448,11 +1448,12 @@ fn (mut p Parser) dot_expr(left ast.Expr) ast.Expr {
// `.green`
// `pref.BuildMode.default_mode`
fn (mut p Parser) enum_val() ast.EnumVal {
start_pos := p.tok.position()
p.check(.dot)
val := p.check_name()
return ast.EnumVal{
val: val
pos: p.tok.position()
pos: start_pos.extend(p.prev_tok.position())
}
}

View File

@ -0,0 +1,6 @@
vlib/v/parser/tests/expected_type_enum_err.vv:6:12: error: expected type is not an enum (`rune`)
4 |
5 | fn main() {
6 | if `c` == .bar {}
| ~~~~
7 | }

View File

@ -0,0 +1,7 @@
module main
enum Test { bar }
fn main() {
if `c` == .bar {}
}