mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: set is_public when registering enum type symbols (#8875)
This commit is contained in:
parent
b9edc4a414
commit
7928689ee2
@ -2217,6 +2217,7 @@ $pubfn (mut e $enum_name) toggle(flag $enum_name) { unsafe{ *e = ${enum_name}
|
|||||||
is_flag: is_flag
|
is_flag: is_flag
|
||||||
is_multi_allowed: is_multi_allowed
|
is_multi_allowed: is_multi_allowed
|
||||||
}
|
}
|
||||||
|
is_public: is_pub
|
||||||
})
|
})
|
||||||
if idx == -1 {
|
if idx == -1 {
|
||||||
p.error_with_pos('cannot register enum `$name`, another type with this name exists',
|
p.error_with_pos('cannot register enum `$name`, another type with this name exists',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module main
|
module main
|
||||||
|
|
||||||
import geometry { Point, Line, point_str, module_name }
|
import geometry { Point, Line, Shape, point_str, module_name }
|
||||||
|
|
||||||
fn test_imported_symbols_types() {
|
fn test_imported_symbols_types() {
|
||||||
// struct init
|
// struct init
|
||||||
@ -24,3 +24,15 @@ fn test_imported_symbols_functions() {
|
|||||||
fn test_imported_symbols_constants() {
|
fn test_imported_symbols_constants() {
|
||||||
assert module_name == 'geometry'
|
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
|
||||||
|
}
|
||||||
|
@ -4,6 +4,12 @@ const(
|
|||||||
module_name = 'geometry'
|
module_name = 'geometry'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
pub enum Shape {
|
||||||
|
circle
|
||||||
|
rectangle
|
||||||
|
triangle
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Point {
|
pub struct Point {
|
||||||
pub mut:
|
pub mut:
|
||||||
x int
|
x int
|
||||||
|
Loading…
Reference in New Issue
Block a user