diff --git a/src/compiler/irgen.js b/src/compiler/irgen.js index 39707ef5c6..b1b8ded5e3 100644 --- a/src/compiler/irgen.js +++ b/src/compiler/irgen.js @@ -202,7 +202,7 @@ class ScriptTreeGenerator { }; } return { - kind: 'args.stringNumber', + kind: 'procedures.argument', index: index }; } @@ -223,7 +223,7 @@ class ScriptTreeGenerator { }; } return { - kind: 'args.boolean', + kind: 'procedures.argument', index: index }; } diff --git a/src/compiler/jsgen.js b/src/compiler/jsgen.js index d3e7784d81..914e5cc72b 100644 --- a/src/compiler/jsgen.js +++ b/src/compiler/jsgen.js @@ -433,11 +433,6 @@ class JSGenerator { case 'addons.call': return new TypedInput(`(${this.descendAddonCall(node)})`, TYPE_UNKNOWN); - case 'args.boolean': - return new TypedInput(`toBoolean(p${node.index})`, TYPE_BOOLEAN); - case 'args.stringNumber': - return new TypedInput(`p${node.index}`, TYPE_UNKNOWN); - case 'compat': // Compatibility layer inputs never use flags. return new TypedInput(`(${this.generateCompatibilityLayerCall(node, false)})`, TYPE_UNKNOWN); @@ -665,6 +660,8 @@ class JSGenerator { } return new TypedInput(`${procedureReference}(${joinedArgs})`, TYPE_UNKNOWN); } + case 'procedures.argument': + return new TypedInput(`p${node.index}`, TYPE_UNKNOWN); case 'sensing.answer': return new TypedInput(`runtime.ext_scratch3_sensing._answer`, TYPE_STRING); diff --git a/test/fixtures/execute/tw-boolean-arguments-are-not-cast.sb3 b/test/fixtures/execute/tw-boolean-arguments-are-not-cast.sb3 new file mode 100644 index 0000000000..ba78ae2119 Binary files /dev/null and b/test/fixtures/execute/tw-boolean-arguments-are-not-cast.sb3 differ diff --git a/test/snapshot/__snapshots__/tw-boolean-arguments-are-not-cast.sb3.tw-snapshot b/test/snapshot/__snapshots__/tw-boolean-arguments-are-not-cast.sb3.tw-snapshot new file mode 100644 index 0000000000..bb3be7cad3 --- /dev/null +++ b/test/snapshot/__snapshots__/tw-boolean-arguments-are-not-cast.sb3.tw-snapshot @@ -0,0 +1,24 @@ +// TW Snapshot +// Input SHA-256: 9ecff9e3c4b1dcdf3e23d0e49c0a2da3de446b6d626a2b5ee39d761be20344ca + +// Sprite1 script +(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage(); +const b0 = runtime.getOpcodeFunction("looks_say"); +return function* genXYZ () { +yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "f", null); +yield* thread.procedures["ZBlock A %s"]("Hai!!!"); +yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "k", null); +retire(); return; +}; }) + +// Sprite1 ZBlock A %s +(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage(); +const b0 = runtime.getOpcodeFunction("looks_say"); +return function* genXYZ_Block_A_ (p0) { +if ((("" + p0).toLowerCase() === "Hai!!!".toLowerCase())) { +yield* executeInCompatibilityLayer({"MESSAGE":"pass did not cast",}, b0, false, false, "m", null); +} else { +yield* executeInCompatibilityLayer({"MESSAGE":"fail was casted",}, b0, false, false, "n", null); +} +return ""; +}; }) diff --git a/test/snapshot/__snapshots__/warp-timer/tw-boolean-arguments-are-not-cast.sb3.tw-snapshot b/test/snapshot/__snapshots__/warp-timer/tw-boolean-arguments-are-not-cast.sb3.tw-snapshot new file mode 100644 index 0000000000..bb3be7cad3 --- /dev/null +++ b/test/snapshot/__snapshots__/warp-timer/tw-boolean-arguments-are-not-cast.sb3.tw-snapshot @@ -0,0 +1,24 @@ +// TW Snapshot +// Input SHA-256: 9ecff9e3c4b1dcdf3e23d0e49c0a2da3de446b6d626a2b5ee39d761be20344ca + +// Sprite1 script +(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage(); +const b0 = runtime.getOpcodeFunction("looks_say"); +return function* genXYZ () { +yield* executeInCompatibilityLayer({"MESSAGE":"plan 1",}, b0, false, false, "f", null); +yield* thread.procedures["ZBlock A %s"]("Hai!!!"); +yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "k", null); +retire(); return; +}; }) + +// Sprite1 ZBlock A %s +(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage(); +const b0 = runtime.getOpcodeFunction("looks_say"); +return function* genXYZ_Block_A_ (p0) { +if ((("" + p0).toLowerCase() === "Hai!!!".toLowerCase())) { +yield* executeInCompatibilityLayer({"MESSAGE":"pass did not cast",}, b0, false, false, "m", null); +} else { +yield* executeInCompatibilityLayer({"MESSAGE":"fail was casted",}, b0, false, false, "n", null); +} +return ""; +}; })