Skip to content

Commit 07309b6

Browse files
committed
Use more specific type for string length
1 parent d09f82a commit 07309b6

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/compiler/irgen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ class ScriptTreeGenerator {
344344
right: this.descendInputOfBlock(block, 'STRING2').toType(InputType.STRING)
345345
});
346346
case 'operator_length':
347-
return new IntermediateInput(InputOpcode.OP_LENGTH, InputType.NUMBER_REAL, {
347+
return new IntermediateInput(InputOpcode.OP_LENGTH, InputType.NUMBER_POS_INT | InputType.NUMBER_ZERO, {
348348
string: this.descendInputOfBlock(block, 'STRING').toType(InputType.STRING)
349349
});
350350
case 'operator_letter_of':

test/snapshot/__snapshots__/tw-simple-string-operations.sb3.tw-snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ return function funXYZ_a () {
2424
b0.value = "ababa";
2525
b1.value = "";
2626
b2.value = 1;
27-
for (var a0 = ("" + b0.value).length; a0 >= 0.5; a0--) {
27+
for (var a0 = ("" + b0.value).length; a0 > 0; a0--) {
2828
if ((((("" + b0.value))[(b2.value | 0) - 1] || "").toLowerCase() === "a".toLowerCase())) {
2929
b1.value = (("" + b1.value) + "b");
3030
} else {

test/snapshot/__snapshots__/warp-timer/tw-simple-string-operations.sb3.tw-snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ return function* genXYZ_a () {
2424
b0.value = "ababa";
2525
b1.value = "";
2626
b2.value = 1;
27-
for (var a0 = ("" + b0.value).length; a0 >= 0.5; a0--) {
27+
for (var a0 = ("" + b0.value).length; a0 > 0; a0--) {
2828
if ((((("" + b0.value))[((+b2.value) | 0) - 1] || "").toLowerCase() === "a".toLowerCase())) {
2929
b1.value = (("" + b1.value) + "b");
3030
} else {

0 commit comments

Comments
 (0)