Emit an error when declaring a nullable basic type (for now)

This commit is contained in:
dcode
2019-01-30 10:22:15 +01:00
parent 53db37f2e8
commit 7877661f35
3 changed files with 10 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -0,0 +1,2 @@
var a: i32 | null;
// Expect error: AS204