match: else

pull/1198/head
Alexander Medvednikov 2019-07-17 02:47:45 +02:00
parent 76d6e9fd1a
commit 14ad70d3a0
2 changed files with 12 additions and 6 deletions

View File

@ -3044,8 +3044,13 @@ fn (p mut Parser) switch_statement() {
for p.tok == .key_case || p.tok == .key_default || p.peek() == .arrow || p.tok == .key_else {
if p.tok == .key_default || p.tok == .key_else {
p.genln('else { // default:')
p.check(.key_default)
p.check(.colon)
if p.tok == .key_default {
p.check(.key_default)
p.check(.colon)
} else {
p.check(.key_else)
p.check(.arrow)
}
p.statements()
break
}

View File

@ -2,10 +2,11 @@ fn test_match() {
a := 3
mut b := 0
match a {
2 => println('two')
3 => println('three')
b = 3
4 => println('four')
2 => println('two')
3 => println('three')
b = 3
4 => println('four')
else => println('???')
}
assert b == 3
}