Skip to content

Complier bug: resetVariableInputs() is not executed when executing generateCompatibilityLayerCall() #245

@Arkos123

Description

@Arkos123

Bug Description

  • The resetVariableInputs() function is not called within the generateCompatibilityLayerCall function in jsgen.js. This might lead to a situation where, when executing extension blocks or blocks like "say ... for ... secs", after a thread switch, the type records of VariableInputs are not cleared in a timely manner.
    generateCompatibilityLayerCall (node, setFlags, frameName = null) {
    const opcode = node.opcode;
    let result = 'yield* executeInCompatibilityLayer({';

Bug Behavior

As shown in the image below, when calculating "(my var) + 2", the compiler does not convert "my var" to a number. Instead, it directly performs string joining.

  • When executing the block "say ... for 0.1 secs", resetVariableInputs() is not called. At this point, the program switches to another script, which changes "my var" from a number to a string.
  • When returning to the original script and compiling "(my var) + 2", the compiler still assumes that "my var" is a number and does not perform type conversion, resulting in an error.
  • Similar bugs may also occur with extension blocks that can cause thread switches.

Suggested Change

  • Add a call to resetVariableInputs() within the generateCompatibilityLayerCall function in jsgen.js
    generateCompatibilityLayerCall (node, setFlags, frameName = null) {
    const opcode = node.opcode;
    let result = 'yield* executeInCompatibilityLayer({';

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions