checker: show error instead of panic, when using a `somemodule.NonExistingEnum.enum_value` (#13295)
parent
1f20127502
commit
edc6c9e24f
|
@ -3708,6 +3708,10 @@ pub fn (mut c Checker) enum_val(mut node ast.EnumVal) ast.Type {
|
|||
c.error('unknown enum `$node.enum_name` (type_idx=0)', node.pos)
|
||||
return ast.void_type
|
||||
}
|
||||
} else {
|
||||
// if module prefix specified enum name given
|
||||
c.error('unknown enum `$node.enum_name` (type_idx=0)', node.pos)
|
||||
return ast.void_type
|
||||
}
|
||||
}
|
||||
mut typ := ast.new_type(typ_idx)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
vlib/v/checker/tests/enum_error_module.vv:5:13: error: unknown enum `missing_enum.ColoList` (type_idx=0)
|
||||
3 | fn main() {
|
||||
4 | mut c := me.Color{
|
||||
5 | color: me.ColoList.black
|
||||
| ~~~~~~~~~~~~~~
|
||||
6 | }
|
||||
7 | println(c)
|
|
@ -0,0 +1,8 @@
|
|||
import missing_enum as me
|
||||
|
||||
fn main() {
|
||||
mut c := me.Color{
|
||||
color: me.ColoList.black
|
||||
}
|
||||
println(c)
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
vlib/v/checker/tests/modules/missing_enum/main.v:1:1: error: project must include a `main` module or be a shared library (compile with `v -shared`)
|
||||
1 | module missing_enum
|
||||
| ^
|
||||
2 |
|
||||
3 | pub enum ColorList {
|
|
@ -0,0 +1,12 @@
|
|||
module missing_enum
|
||||
|
||||
pub enum ColorList {
|
||||
red
|
||||
blue
|
||||
green
|
||||
black
|
||||
}
|
||||
|
||||
pub struct Color {
|
||||
color ColorList
|
||||
}
|
Loading…
Reference in New Issue