mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: check unknown chan element type (#14843)
This commit is contained in:
parent
90287f6aaa
commit
ef643e106b
@ -3523,6 +3523,12 @@ pub fn (mut c Checker) chan_init(mut node ast.ChanInit) ast.Type {
|
||||
if node.typ != 0 {
|
||||
info := c.table.sym(node.typ).chan_info()
|
||||
node.elem_type = info.elem_type
|
||||
if node.elem_type != 0 {
|
||||
elem_sym := c.table.sym(node.elem_type)
|
||||
if elem_sym.kind == .placeholder {
|
||||
c.error('unknown type `$elem_sym.name`', node.pos)
|
||||
}
|
||||
}
|
||||
if node.has_cap {
|
||||
c.check_array_init_para_type('cap', node.cap_expr, node.pos)
|
||||
}
|
||||
|
5
vlib/v/checker/tests/chan_elem_type_unknown.out
Normal file
5
vlib/v/checker/tests/chan_elem_type_unknown.out
Normal file
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/chan_elem_type_unknown.vv:2:7: error: unknown type `NonExistingType`
|
||||
1 | fn main() {
|
||||
2 | _ := chan NonExistingType{}
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~
|
||||
3 | }
|
3
vlib/v/checker/tests/chan_elem_type_unknown.vv
Normal file
3
vlib/v/checker/tests/chan_elem_type_unknown.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
_ := chan NonExistingType{}
|
||||
}
|
Loading…
Reference in New Issue
Block a user