mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
parent
dafca9353c
commit
7b8e059a3c
5 changed files with 48 additions and 0 deletions
|
@ -3191,6 +3191,11 @@ fn (mut c Checker) cast_expr(mut node ast.CastExpr) ast.Type {
|
|||
return to_type
|
||||
}
|
||||
|
||||
if !c.expected_type.has_flag(.generic) && to_sym.name.len == 1
|
||||
&& to_sym.name.starts_with_capital() {
|
||||
c.error('unknown type `${to_sym.name}`', node.pos)
|
||||
}
|
||||
|
||||
if to_sym.language != .c {
|
||||
c.ensure_type_exists(to_type, node.pos)
|
||||
|
||||
|
|
13
vlib/v/checker/tests/cast_expr_T_type_err.out
Normal file
13
vlib/v/checker/tests/cast_expr_T_type_err.out
Normal file
|
@ -0,0 +1,13 @@
|
|||
vlib/v/checker/tests/cast_expr_T_type_err.vv:4:9: error: unknown type `A`
|
||||
2 |
|
||||
3 | fn main() {
|
||||
4 | _ = A(0)
|
||||
| ~~~~
|
||||
5 | _ = &A(0)
|
||||
6 | }
|
||||
vlib/v/checker/tests/cast_expr_T_type_err.vv:5:9: error: unknown type `A`
|
||||
3 | fn main() {
|
||||
4 | _ = A(0)
|
||||
5 | _ = &A(0)
|
||||
| ~~~~~
|
||||
6 | }
|
6
vlib/v/checker/tests/cast_expr_T_type_err.vv
Normal file
6
vlib/v/checker/tests/cast_expr_T_type_err.vv
Normal file
|
@ -0,0 +1,6 @@
|
|||
module main
|
||||
|
||||
fn main() {
|
||||
_ = A(0)
|
||||
_ = &A(0)
|
||||
}
|
14
vlib/v/checker/tests/globals/cast_expr_T_type_err.out
Normal file
14
vlib/v/checker/tests/globals/cast_expr_T_type_err.out
Normal file
|
@ -0,0 +1,14 @@
|
|||
vlib/v/checker/tests/globals/cast_expr_T_type_err.vv:4:7: error: unknown type `A`
|
||||
2 |
|
||||
3 | __global (
|
||||
4 | fo = A(0)
|
||||
| ~~~~
|
||||
5 | fo1 = &A(0)
|
||||
6 | )
|
||||
vlib/v/checker/tests/globals/cast_expr_T_type_err.vv:5:8: error: unknown type `A`
|
||||
3 | __global (
|
||||
4 | fo = A(0)
|
||||
5 | fo1 = &A(0)
|
||||
| ~~~~~
|
||||
6 | )
|
||||
7 |
|
10
vlib/v/checker/tests/globals/cast_expr_T_type_err.vv
Normal file
10
vlib/v/checker/tests/globals/cast_expr_T_type_err.vv
Normal file
|
@ -0,0 +1,10 @@
|
|||
module main
|
||||
|
||||
__global (
|
||||
fo = A(0)
|
||||
fo1 = &A(0)
|
||||
)
|
||||
|
||||
fn main() {
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue