Skip to content

Commit 5057e3b

Browse files
committed
Change null references to be not implemented yet
1 parent fc5953b commit 5057e3b

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/compiler.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8271,7 +8271,12 @@ export class Compiler extends DiagnosticEmitter {
82718271
this.currentType = signatureReference.type.asNullable();
82728272
return module.i32(0);
82738273
}
8274-
return module.ref_null();
8274+
// TODO: return null ref for externref or funcref
8275+
this.error(
8276+
DiagnosticCode.Not_implemented_0,
8277+
expression.range,
8278+
"null references"
8279+
);
82758280
}
82768281
this.currentType = options.usizeType;
82778282
this.warning(
@@ -10653,7 +10658,10 @@ export class Compiler extends DiagnosticEmitter {
1065310658
case TypeKind.F32: return module.f32(0);
1065410659
case TypeKind.F64: return module.f64(0);
1065510660
case TypeKind.V128: return module.v128(v128_zero);
10656-
case TypeKind.EXTERNREF: return module.ref_null();
10661+
case TypeKind.EXTERNREF:
10662+
// TODO: return null ref for both externref as well as funcref
10663+
assert(false, 'null for externref is not yet supported');
10664+
return module.unreachable();
1065710665
}
1065810666
}
1065910667

tests/compiler/features/reference-types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ console.log(someObject);
2626
console.log(someKey);
2727
console.log(Reflect.get(someObject, someKey));
2828

29-
// can represent and recognize 'null'
30-
31-
var nullGlobal: externref;
29+
// TODO: can represent and recognize 'null' for both externref and funcref
30+
/* var nullGlobal: externref;
3231
assert(!nullGlobal);
3332
nullGlobal = null;
3433
assert(!nullGlobal);
@@ -43,10 +42,11 @@ assert(!nullGlobalInit);
4342
assert(!nullLocalInit);
4443
}
4544
46-
// can represent function references
45+
// funcref can represent function references
4746
4847
function someFunc(): void {}
4948
var funcGlobal: externref = someFunc;
5049
{
5150
let funcLocal: externref = someFunc;
5251
}
52+
*/

0 commit comments

Comments
 (0)