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
12 changes: 8 additions & 4 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5541,11 +5541,11 @@ export class Compiler extends DiagnosticEmitter {
let rightFlow = flow.fork();
this.currentFlow = rightFlow;
rightFlow.inheritNonnullIfTrue(leftExpr);
rightExpr = this.compileExpression(right, leftType, inheritedConstraints | Constraints.CONV_IMPLICIT);
rightType = leftType;

// simplify if only interested in true or false
if (contextualType == Type.bool || contextualType == Type.void) {
rightExpr = this.compileExpression(right, leftType, inheritedConstraints);
rightType = this.currentType;
rightExpr = this.performAutoreleasesWithValue(rightFlow, rightExpr, rightType);
rightFlow.freeScopedLocals();
this.currentFlow = flow;
Expand All @@ -5557,6 +5557,8 @@ export class Compiler extends DiagnosticEmitter {
this.currentType = Type.bool;

} else {
rightExpr = this.compileExpression(right, leftType, inheritedConstraints | Constraints.CONV_IMPLICIT);
rightType = this.currentType;

// references must properly retain and release, with the same outcome independent of the branch taken
if (leftType.isManaged) {
Expand Down Expand Up @@ -5643,11 +5645,11 @@ export class Compiler extends DiagnosticEmitter {
let rightFlow = flow.fork();
this.currentFlow = rightFlow;
rightFlow.inheritNonnullIfFalse(leftExpr);
rightExpr = this.compileExpression(right, leftType, inheritedConstraints | Constraints.CONV_IMPLICIT);
rightType = leftType;

// simplify if only interested in true or false
if (contextualType == Type.bool || contextualType == Type.void) {
rightExpr = this.compileExpression(right, leftType, inheritedConstraints);
rightType = this.currentType;
rightExpr = this.performAutoreleasesWithValue(rightFlow, rightExpr, leftType);
rightFlow.freeScopedLocals();
this.currentFlow = flow;
Expand All @@ -5659,6 +5661,8 @@ export class Compiler extends DiagnosticEmitter {
this.currentType = Type.bool;

} else {
rightExpr = this.compileExpression(right, leftType, inheritedConstraints | Constraints.CONV_IMPLICIT);
rightType = this.currentType;

// references must properly retain and release, with the same outcome independent of the branch taken
if (leftType.isManaged) {
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/logical.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"asc_flags": [
"--runtime none"
"--runtime half",
"--use ASC_RTRACE=1"
]
}
Loading