nice enum works

pull/2532/head
Alexander Medvednikov 2019-10-24 14:56:02 +03:00
parent dca49e43d9
commit 560ae9352c
2 changed files with 7 additions and 1 deletions

View File

@ -2456,7 +2456,7 @@ fn (p mut Parser) indot_expr() string {
if p.tok == .key_in { if p.tok == .key_in {
p.fgen(' ') p.fgen(' ')
p.check(.key_in) p.check(.key_in)
//if p.pref.is_debug && p.tok == .lsbr { p.expected_type = typ // this allows `foo in [.val1, .val2, .val3]`
if p.tok == .lsbr { if p.tok == .lsbr {
// a in [1,2,3] optimization => `a == 1 || a == 2 || a == 3` // a in [1,2,3] optimization => `a == 1 || a == 2 || a == 3`
// avoids an allocation // avoids an allocation

View File

@ -22,3 +22,9 @@ fn test_enum() {
color = .green color = .green
assert color == Color.green assert color == Color.green
} }
fn test_in() {
color := Color.red
num := 3
assert color in [.red, .green]
}