parser: fix Enum.value when Enum is an imported symbol (#9046)

pull/9189/head
zakuro 2021-03-08 00:44:38 +09:00 committed by GitHub
parent a1e0f2bc46
commit 4c3ce97763
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -1391,7 +1391,7 @@ pub fn (mut p Parser) name_expr() ast.Expr {
if mod != '' {
enum_name = mod + '.' + enum_name
} else {
enum_name = p.prepend_mod(enum_name)
enum_name = p.imported_symbols[enum_name] or { p.prepend_mod(enum_name) }
}
// p.warn('Color.green $enum_name ' + p.prepend_mod(enum_name) + 'mod=$mod')
p.check(.dot)

View File

@ -15,7 +15,7 @@ fn test_imported_symbols_types() {
fn test_imported_symbols_functions() {
p0 := Point{x: 20 y: 40}
// method
// method
assert p0.str() == '20 40'
// function
assert point_str(p0) == '20 40'
@ -35,4 +35,5 @@ fn vertex_count(s Shape) int {
fn test_imported_symbols_enums() {
assert vertex_count(.triangle) == 3
assert vertex_count(Shape.triangle) == 3
}