mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-11 22:11:27 +00:00
Emit an error when declaring a nullable basic type (for now)
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
2
tests/compiler/basic-nullable.ts
Normal file
2
tests/compiler/basic-nullable.ts
Normal file
@ -0,0 +1,2 @@
|
||||
var a: i32 | null;
|
||||
// Expect error: AS204
|
0
tests/compiler/basic-nullable.untouched.wat
Normal file
0
tests/compiler/basic-nullable.untouched.wat
Normal file
Reference in New Issue
Block a user