parser: resolve optional enum type
parent
2fbfbf45c7
commit
bf9eefa694
|
@ -119,6 +119,9 @@ int typ;
|
|||
}
|
||||
|
||||
fn (p mut Parser) check_enum_member_access() {
|
||||
if p.expected_type.starts_with('Option_') {
|
||||
p.expected_type = p.expected_type[7..]
|
||||
}
|
||||
T := p.find_type(p.expected_type)
|
||||
if T.cat == .enum_ {
|
||||
p.check(.dot)
|
||||
|
|
|
@ -4,6 +4,21 @@ enum Color {
|
|||
green
|
||||
}
|
||||
|
||||
fn enum_optional_helper(b bool) ?Color {
|
||||
if b {
|
||||
return .red
|
||||
}
|
||||
return error('failed')
|
||||
}
|
||||
|
||||
fn test_enum_optional() {
|
||||
a := enum_optional_helper(true) or {
|
||||
assert false
|
||||
return
|
||||
}
|
||||
assert a == .red
|
||||
}
|
||||
|
||||
fn test_enum() {
|
||||
assert Color.red == .red
|
||||
assert Color.blue == .blue
|
||||
|
|
Loading…
Reference in New Issue