parser: add a check for known vars in or block (#7094)
parent
30da85a4d5
commit
c5a7c51dfd
|
@ -645,7 +645,7 @@ pub fn (mut p Parser) stmt(is_top_level bool) ast.Stmt {
|
|||
} else if p.peek_tok.kind == .name {
|
||||
p.error_with_pos('unexpected name `$p.peek_tok.lit`', p.peek_tok.position())
|
||||
} else if !p.inside_if_expr && !p.inside_match_body && !p.inside_or_expr &&
|
||||
p.peek_tok.kind in [.rcbr, .eof] {
|
||||
p.peek_tok.kind in [.rcbr, .eof] && !p.mark_var_as_used(p.tok.lit) {
|
||||
p.error_with_pos('`$p.tok.lit` evaluated but not used', p.tok.position())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,3 +154,13 @@ fn test_nested_optional_with_opt_fn_call_as_last_value() {
|
|||
// }
|
||||
// assert e == false
|
||||
}
|
||||
|
||||
fn remove_suffix1(s string) string {
|
||||
n := s.len
|
||||
i := s.last_index('.') or { n }
|
||||
return s[0..i]
|
||||
}
|
||||
|
||||
fn test_var_inside_or_block() {
|
||||
assert remove_suffix1('Vlang.foo') == 'Vlang'
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue