checker: small cleanup of commit edc6c9e

pull/13311/head
Delyan Angelov 2022-01-28 10:27:37 +02:00
parent edc6c9e24f
commit 71d98717dc
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
5 changed files with 10 additions and 30 deletions

View File

@ -3708,8 +3708,9 @@ 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) c.error('unknown enum `$node.enum_name` (type_idx=0)', node.pos)
return ast.void_type return ast.void_type
} }
} else { }
// if module prefix specified enum name given if typ_idx == 0 {
// the actual type is still unknown, produce an error, instead of panic:
c.error('unknown enum `$node.enum_name` (type_idx=0)', node.pos) c.error('unknown enum `$node.enum_name` (type_idx=0)', node.pos)
return ast.void_type return ast.void_type
} }

View File

@ -1,7 +1,6 @@
vlib/v/checker/tests/enum_error_module.vv:5:13: error: unknown enum `missing_enum.ColoList` (type_idx=0) vlib/v/checker/tests/enum_error_module.vv:4:12: error: unknown enum `time.NonExistingEnum` (type_idx=0)
2 |
3 | fn main() { 3 | fn main() {
4 | mut c := me.Color{ 4 | _ := time.NonExistingEnum.black
5 | color: me.ColoList.black | ~~~~~~~~~~~~~~~~~~~~~
| ~~~~~~~~~~~~~~ 5 | }
6 | }
7 | println(c)

View File

@ -1,8 +1,5 @@
import missing_enum as me import time
fn main() { fn main() {
mut c := me.Color{ _ := time.NonExistingEnum.black
color: me.ColoList.black
}
println(c)
} }

View File

@ -1,5 +0,0 @@
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 {

View File

@ -1,12 +0,0 @@
module missing_enum
pub enum ColorList {
red
blue
green
black
}
pub struct Color {
color ColorList
}