Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6106,6 +6106,15 @@ export class Compiler extends DiagnosticEmitter {
let local = <Local>target;
signature = local.type.signatureReference;
if (signature) {
if (local.parent != flow.parentFunction) {
// TODO: closures
this.error(
DiagnosticCode.Not_implemented_0,
expression.range,
"Closures"
);
return module.unreachable();
}
if (local.is(CommonFlags.INLINED)) {
let inlinedValue = local.constantIntegerValue;
if (this.options.isWasm64) {
Expand Down
2 changes: 2 additions & 0 deletions tests/compiler/closure.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"$local0; // closure 2",
"AS100: Not implemented: Closures",
"$local0; // closure 3",
"AS100: Not implemented: Closures",
"$local0(123); // closure 4",
"EOF"
]
}
7 changes: 7 additions & 0 deletions tests/compiler/closure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ function testLet(): (value: i32) => i32 {
}
testLet();

function testFuncParam($local0: (x: i32) => void): () => void {
return () => {
$local0(123); // closure 4
};
}
testFuncParam((x: i32) => {});

ERROR("EOF");