diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 46f128f9cf..5e0f0c0257 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -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 {} diff --git a/vlib/v/checker/tests/type_alias_none_parent_type_err.out b/vlib/v/checker/tests/type_alias_none_parent_type_err.out new file mode 100644 index 0000000000..fec00f0eec --- /dev/null +++ b/vlib/v/checker/tests/type_alias_none_parent_type_err.out @@ -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 + | ~~~~ diff --git a/vlib/v/checker/tests/type_alias_none_parent_type_err.vv b/vlib/v/checker/tests/type_alias_none_parent_type_err.vv new file mode 100644 index 0000000000..9820150613 --- /dev/null +++ b/vlib/v/checker/tests/type_alias_none_parent_type_err.vv @@ -0,0 +1 @@ +type None = none