parser: `x in []` is always false

pull/3006/head
Alexander Medvednikov 2019-12-07 03:05:19 +03:00
parent 5a8c07dcf5
commit cc834dd7a7
1 changed files with 3 additions and 0 deletions

View File

@ -6,6 +6,9 @@ module compiler
// `ph` is for string_eq() // `ph` is for string_eq()
fn (p mut Parser) in_optimization(typ string, ph int) { fn (p mut Parser) in_optimization(typ string, ph int) {
p.check(.lsbr) p.check(.lsbr)
if p.tok == .rsbr {
p.error('`x in []` is always false')
}
mut i := 0 mut i := 0
// Get `a` expr value (can be a string literal, not a variable) // Get `a` expr value (can be a string literal, not a variable)
expr := p.cgen.cur_line[ph..] expr := p.cgen.cur_line[ph..]