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:
parent
25153490e1
commit
597c2249e0
@ -1448,11 +1448,12 @@ fn (mut p Parser) dot_expr(left ast.Expr) ast.Expr {
|
|||||||
// `.green`
|
// `.green`
|
||||||
// `pref.BuildMode.default_mode`
|
// `pref.BuildMode.default_mode`
|
||||||
fn (mut p Parser) enum_val() ast.EnumVal {
|
fn (mut p Parser) enum_val() ast.EnumVal {
|
||||||
|
start_pos := p.tok.position()
|
||||||
p.check(.dot)
|
p.check(.dot)
|
||||||
val := p.check_name()
|
val := p.check_name()
|
||||||
return ast.EnumVal{
|
return ast.EnumVal{
|
||||||
val: val
|
val: val
|
||||||
pos: p.tok.position()
|
pos: start_pos.extend(p.prev_tok.position())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
vlib/v/parser/tests/expected_type_enum_err.out
Normal file
6
vlib/v/parser/tests/expected_type_enum_err.out
Normal 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 | }
|
7
vlib/v/parser/tests/expected_type_enum_err.vv
Normal file
7
vlib/v/parser/tests/expected_type_enum_err.vv
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module main
|
||||||
|
|
||||||
|
enum Test { bar }
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
if `c` == .bar {}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user