mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: explicitly disallow creating type aliases of none
, i.e. type Abc = none
(#19078)
This commit is contained in:
parent
286d39706b
commit
8db1aaafd5
@ -526,6 +526,9 @@ fn (mut c Checker) alias_type_decl(node ast.AliasTypeDecl) {
|
||||
// type Sum = int | Alias
|
||||
// type Alias = Sum
|
||||
}
|
||||
.none_ {
|
||||
c.error('cannot create a type alias of `none` as it is a value', node.type_pos)
|
||||
}
|
||||
// The rest of the parent symbol kinds are also allowed, since they are either primitive types,
|
||||
// that in turn do not allow recursion, or are abstract enough so that they can not be checked at comptime:
|
||||
else {}
|
||||
|
3
vlib/v/checker/tests/type_alias_none_parent_type_err.out
Normal file
3
vlib/v/checker/tests/type_alias_none_parent_type_err.out
Normal file
@ -0,0 +1,3 @@
|
||||
vlib/v/checker/tests/type_alias_none_parent_type_err.vv:1:13: error: cannot create a type alias of `none` as it is a value
|
||||
1 | type None = none
|
||||
| ~~~~
|
1
vlib/v/checker/tests/type_alias_none_parent_type_err.vv
Normal file
1
vlib/v/checker/tests/type_alias_none_parent_type_err.vv
Normal file
@ -0,0 +1 @@
|
||||
type None = none
|
Loading…
Reference in New Issue
Block a user