diff --git a/src/resolver.ts b/src/resolver.ts index 84a3fde3..33f5f883 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -196,6 +196,14 @@ export class Resolver extends DiagnosticEmitter { (type = typesLookup.get(localName)) || (type = typesLookup.get(globalName)) ) { + if (!type.is(TypeFlags.REFERENCE) && node.isNullable) { + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode.Basic_type_0_cannot_be_nullable, + node.range, type.toString() + ); + } + } return type; } } diff --git a/tests/compiler/basic-nullable.ts b/tests/compiler/basic-nullable.ts new file mode 100644 index 00000000..e3c9f36f --- /dev/null +++ b/tests/compiler/basic-nullable.ts @@ -0,0 +1,2 @@ +var a: i32 | null; +// Expect error: AS204 diff --git a/tests/compiler/basic-nullable.untouched.wat b/tests/compiler/basic-nullable.untouched.wat new file mode 100644 index 00000000..e69de29b