mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parent
5498a6c263
commit
9231697966
@ -35,10 +35,6 @@ pub fn (mut c Checker) struct_decl(mut node ast.StructDecl) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i, field in node.fields {
|
for i, field in node.fields {
|
||||||
if field.typ == ast.any_type {
|
|
||||||
c.error('struct field cannot be the `any` type, use generics instead',
|
|
||||||
field.type_pos)
|
|
||||||
}
|
|
||||||
c.ensure_type_exists(field.typ, field.type_pos) or { return }
|
c.ensure_type_exists(field.typ, field.type_pos) or { return }
|
||||||
if field.typ.has_flag(.generic) {
|
if field.typ.has_flag(.generic) {
|
||||||
has_generic_types = true
|
has_generic_types = true
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
vlib/v/checker/tests/struct_field_with_any_type_err.vv:2:6: error: struct field cannot be the `any` type, use generics instead
|
vlib/v/checker/tests/struct_field_with_any_type_err.vv:2:6: error: cannot use `any` type here, `any` will be implemented in V 0.4
|
||||||
1 | struct My_type {
|
1 | struct My_type {
|
||||||
2 | fld any
|
2 | fld any
|
||||||
| ~~~
|
| ~~~
|
||||||
|
@ -607,6 +607,12 @@ pub fn (mut p Parser) parse_any_type(language ast.Language, is_ptr bool, check_d
|
|||||||
'int_literal' {
|
'int_literal' {
|
||||||
ret = ast.int_literal_type
|
ret = ast.int_literal_type
|
||||||
}
|
}
|
||||||
|
'any' {
|
||||||
|
if p.file_backend_mode != .js && p.mod != 'builtin' {
|
||||||
|
p.error('cannot use `any` type here, `any` will be implemented in V 0.4')
|
||||||
|
}
|
||||||
|
ret = ast.any_type
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
p.next()
|
p.next()
|
||||||
if name.len == 1 && name[0].is_capital() {
|
if name.len == 1 && name[0].is_capital() {
|
||||||
|
6
vlib/v/parser/tests/cast_to_any_type_err.out
Normal file
6
vlib/v/parser/tests/cast_to_any_type_err.out
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
vlib/v/parser/tests/cast_to_any_type_err.vv:2:7: error: cannot use `any` type here, `any` will be implemented in V 0.4
|
||||||
|
1 | fn main() {
|
||||||
|
2 | a := any(22)
|
||||||
|
| ~~~
|
||||||
|
3 | println(a)
|
||||||
|
4 | }
|
4
vlib/v/parser/tests/cast_to_any_type_err.vv
Normal file
4
vlib/v/parser/tests/cast_to_any_type_err.vv
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
fn main() {
|
||||||
|
a := any(22)
|
||||||
|
println(a)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user