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
8 changes: 5 additions & 3 deletions src/builtins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,8 @@ function builtin_max(ctx: BuiltinContext): ExpressionRef {
module.binary(op,
module.local_get(temp1.index, typeRef),
module.local_get(temp2.index, typeRef)
)
),
typeRef
);
flow.freeTempLocal(temp2);
flow.freeTempLocal(temp1);
Expand Down Expand Up @@ -1633,7 +1634,8 @@ function builtin_min(ctx: BuiltinContext): ExpressionRef {
module.binary(op,
module.local_get(temp1.index, typeRef),
module.local_get(temp2.index, typeRef)
)
),
typeRef
);
flow.freeTempLocal(temp2);
flow.freeTempLocal(temp1);
Expand Down Expand Up @@ -2770,7 +2772,7 @@ function builtin_select(ctx: BuiltinContext): ExpressionRef {
operands[2]
);
compiler.currentType = type;
return module.select(arg0, arg1, arg2);
return module.select(arg0, arg1, arg2, type.toRef());
}
builtins.set(BuiltinNames.select, builtin_select);

Expand Down
3 changes: 2 additions & 1 deletion src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5245,7 +5245,8 @@ export class Compiler extends DiagnosticEmitter {
return module.select(
module.i32(1),
module.binary(BinaryOp.EqI32, rightExpr, module.i32(0)),
leftExpr
leftExpr,
TypeRef.I32
);
}
case TypeKind.I8:
Expand Down
6 changes: 1 addition & 5 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1475,12 +1475,8 @@ export class Module {
ifTrue: ExpressionRef,
ifFalse: ExpressionRef,
condition: ExpressionRef,
type: TypeRef = TypeRef.Auto
type: TypeRef
): ExpressionRef {
if (type == TypeRef.Auto) {
type = binaryen._BinaryenExpressionGetType(ifTrue);
assert(type == binaryen._BinaryenExpressionGetType(ifFalse));
}
return binaryen._BinaryenSelect(this.ref, condition, ifTrue, ifFalse, type);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/compiler/closure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ testVar();

function testLet(): (value: i32) => i32 {
let $local0 = 0;
return function inner(value: i32) {
return function inner(value: i32): i32 {
return $local0; // closure 3
};
}
Expand Down