Skip to content

Commit 8a463ae

Browse files
committed
Fix(compiler): Bug auto terminating function declaration ✈️
- I am flying from NSK to BLG and it's time for coding 😺
1 parent 2d6c801 commit 8a463ae

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/backend/llvm/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export function passFunctionDeclaration(parent: ts.FunctionDeclaration, ctx: Con
134134
ctx.scope.enclosureFunction = enclosureFnStore;
135135

136136
if (returnType.isVoidTy()) {
137-
if (block.getTerminator()) {
137+
if (!block.getTerminator()) {
138138
irBuilder.createRetVoid();
139139
}
140140

tests/snapshots/math/return.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
return "Hello world";
55
}
66

7+
function returnWithoutArgumentsLiteral(): void {
8+
return;
9+
}
10+
11+
function returnTrueAsBoolean(): boolean {
12+
return true;
13+
}
14+
15+
function returnFalseAsBoolean(): boolean {
16+
return false;
17+
}
18+
719
function returnNumberLiteral(): number {
820
return 5;
921
}
@@ -29,6 +41,9 @@
2941
}
3042

3143
returnStringLiteral();
44+
returnWithoutArgumentsLiteral();
45+
returnTrueAsBoolean();
46+
returnFalseAsBoolean();
3247
returnNumberLiteral();
3348
returnInt8();
3449
returnInt16();

0 commit comments

Comments
 (0)