mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix eval not used in match
This commit is contained in:
parent
27d3800cc3
commit
712fd384ee
@ -166,7 +166,9 @@ fn (mut p Parser) match_expr() ast.MatchExpr {
|
||||
}
|
||||
branch_last_pos := p.tok.position()
|
||||
// p.warn('match block')
|
||||
p.inside_match_body = true
|
||||
stmts := p.parse_block()
|
||||
p.inside_match_body = false
|
||||
pos := token.Position{
|
||||
line_nr: branch_first_pos.line_nr
|
||||
pos: branch_first_pos.pos
|
||||
|
@ -44,6 +44,7 @@ mut:
|
||||
returns bool
|
||||
inside_match bool // to separate `match A { }` from `Struct{}`
|
||||
inside_match_case bool // to separate `match_expr { }` from `Struct{}`
|
||||
inside_match_body bool // to fix eval not used TODO
|
||||
inside_unsafe bool
|
||||
is_stmt_ident bool // true while the beginning of a statement is an ident/selector
|
||||
expecting_type bool // `is Type`, expecting type
|
||||
@ -485,7 +486,7 @@ pub fn (mut p Parser) stmt() ast.Stmt {
|
||||
}
|
||||
} else if p.tok.kind == .name && p.peek_tok.kind == .name {
|
||||
p.error_with_pos('unexpected name `$p.peek_tok.lit`', p.peek_tok.position())
|
||||
} else if p.tok.kind == .name && !p.inside_if_expr && !p.inside_match && !p.inside_or_expr &&
|
||||
} else if p.tok.kind == .name && !p.inside_if_expr && !p.inside_match_body && !p.inside_or_expr &&
|
||||
p.peek_tok.kind in [.rcbr, .eof] {
|
||||
p.error_with_pos('`$p.tok.lit` evaluated but not used', p.tok.position())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user