Skip to content

Commit c082e7a

Browse files
committed
Fix TypeState#after setting variable types to undefined
If a variable existed in `this` but not in `other`, its resulting type would be set to undefined. Changing it to use the type from `this` seems to fix #273.
1 parent 06a0cc9 commit c082e7a

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/compiler/iroptimizer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class TypeState {
9494
after (other) {
9595
return this.mutate(other, varId => {
9696
const otherType = other.variables[varId];
97-
if (otherType !== 0) return otherType;
97+
if (otherType) return otherType;
9898
return this.variables[varId] ?? InputType.ANY;
9999
});
100100
}

test/snapshot/__snapshots__/tw-procedure-return-recursion.sb3.tw-snapshot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ return function* genXYZ () {
1010
yield* executeInCompatibilityLayer({"MESSAGE":"plan 18",}, b0, false, false, "G", null);
1111
b1.value = 0;
1212
b2.value = (yield* thread.procedures["Znon warp recursion should yield %s"](8));
13-
if (((+b1.value || 0) === 4)) {
13+
if ((b1.value === 4)) {
1414
yield* executeInCompatibilityLayer({"MESSAGE":"pass non warp recursion yields",}, b0, false, false, "ao", null);
1515
}
1616
b1.value = 0;
1717
b2.value = thread.procedures["Wwarp recursion should not yield %s"](8);
18-
if (compareEqual(b1.value, 0)) {
18+
if ((b1.value === 0)) {
1919
yield* executeInCompatibilityLayer({"MESSAGE":"pass warp recursion does not yield",}, b0, false, false, "ar", null);
2020
}
2121
b1.value = 0;
2222
b2.value = (yield* thread.procedures["Zfib %s"](7));
23-
if (((+b1.value || 0) === 20)) {
23+
if ((b1.value === 20)) {
2424
yield* executeInCompatibilityLayer({"MESSAGE":"pass non warp fib yielded",}, b0, false, false, "au", null);
2525
}
2626
yield* thread.procedures["Zrecursing yields between each %s"]("initial");

test/snapshot/__snapshots__/warp-timer/tw-procedure-return-recursion.sb3.tw-snapshot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ return function* genXYZ () {
1010
yield* executeInCompatibilityLayer({"MESSAGE":"plan 18",}, b0, false, false, "G", null);
1111
b1.value = 0;
1212
b2.value = (yield* thread.procedures["Znon warp recursion should yield %s"](8));
13-
if (((+b1.value || 0) === 4)) {
13+
if ((b1.value === 4)) {
1414
yield* executeInCompatibilityLayer({"MESSAGE":"pass non warp recursion yields",}, b0, false, false, "ao", null);
1515
}
1616
b1.value = 0;
1717
b2.value = thread.procedures["Wwarp recursion should not yield %s"](8);
18-
if (compareEqual(b1.value, 0)) {
18+
if ((b1.value === 0)) {
1919
yield* executeInCompatibilityLayer({"MESSAGE":"pass warp recursion does not yield",}, b0, false, false, "ar", null);
2020
}
2121
b1.value = 0;
2222
b2.value = (yield* thread.procedures["Zfib %s"](7));
23-
if (((+b1.value || 0) === 20)) {
23+
if ((b1.value === 20)) {
2424
yield* executeInCompatibilityLayer({"MESSAGE":"pass non warp fib yielded",}, b0, false, false, "au", null);
2525
}
2626
yield* thread.procedures["Zrecursing yields between each %s"]("initial");

0 commit comments

Comments
 (0)