diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 853731d965..bf5536282a 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -2217,6 +2217,7 @@ $pubfn (mut e $enum_name) toggle(flag $enum_name) { unsafe{ *e = ${enum_name} is_flag: is_flag is_multi_allowed: is_multi_allowed } + is_public: is_pub }) if idx == -1 { p.error_with_pos('cannot register enum `$name`, another type with this name exists', diff --git a/vlib/v/tests/imported_symbols_test.v b/vlib/v/tests/imported_symbols_test.v index 4224eb9ae5..de8f95c8b2 100644 --- a/vlib/v/tests/imported_symbols_test.v +++ b/vlib/v/tests/imported_symbols_test.v @@ -1,6 +1,6 @@ module main -import geometry { Point, Line, point_str, module_name } +import geometry { Point, Line, Shape, point_str, module_name } fn test_imported_symbols_types() { // struct init @@ -24,3 +24,15 @@ fn test_imported_symbols_functions() { fn test_imported_symbols_constants() { assert module_name == 'geometry' } + +fn vertex_count(s Shape) int { + return match s { + .circle { 0 } + .triangle { 3 } + .rectangle { 4 } + } +} + +fn test_imported_symbols_enums() { + assert vertex_count(.triangle) == 3 +} diff --git a/vlib/v/tests/modules/geometry/geometry.v b/vlib/v/tests/modules/geometry/geometry.v index 375c49c2dd..e4a26e0f29 100644 --- a/vlib/v/tests/modules/geometry/geometry.v +++ b/vlib/v/tests/modules/geometry/geometry.v @@ -4,6 +4,12 @@ const( module_name = 'geometry' ) +pub enum Shape { + circle + rectangle + triangle +} + pub struct Point { pub mut: x int