Skip to content

Commit 7877661

Browse files
committed
Emit an error when declaring a nullable basic type (for now)
1 parent 53db37f commit 7877661

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/resolver.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ export class Resolver extends DiagnosticEmitter {
196196
(type = typesLookup.get(localName)) ||
197197
(type = typesLookup.get(globalName))
198198
) {
199+
if (!type.is(TypeFlags.REFERENCE) && node.isNullable) {
200+
if (reportMode == ReportMode.REPORT) {
201+
this.error(
202+
DiagnosticCode.Basic_type_0_cannot_be_nullable,
203+
node.range, type.toString()
204+
);
205+
}
206+
}
199207
return type;
200208
}
201209
}

tests/compiler/basic-nullable.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
var a: i32 | null;
2+
// Expect error: AS204

tests/compiler/basic-nullable.untouched.wat

Whitespace-only changes.

0 commit comments

Comments
 (0)