Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENA-266] JS TypeError when clicking a procedure in the toolbox #3877

Open
alexcui03 opened this issue Feb 16, 2023 · 0 comments
Open

[ENA-266] JS TypeError when clicking a procedure in the toolbox #3877

alexcui03 opened this issue Feb 16, 2023 · 0 comments

Comments

@alexcui03
Copy link

Expected Behavior

No Error

Actual Behavior

Uncaught TypeError: Cannot read properties of undefined (reading 'opcode')

Steps to Reproduce

  1. create a procedure as the following picture:
    image
  2. run it by clicking the procedure block in the toolbox, we will get the error in console:
    image

Other Infomation

It causes endless loop in development mode.

Related code src/engine/thread.js:

isRecursiveCall (procedureCode) {
    let callCount = 5; // Max number of enclosing procedure calls to examine.
    const sp = this.stack.length - 1;
    for (let i = sp - 1; i >= 0; i--) {
        const block = this.target.blocks.getBlock(this.stack[i]);
        if (block.opcode === 'procedures_call' &&
            block.mutation.proccode === procedureCode) {
            return true;
        }
        if (--callCount < 0) return false;
    }
    return false;
}

Possible reason: the procedure block from toolbox cannot be get with this.target.blocks.getBlock, so it get undefined. Accessing block.opcode (block is undefined) cause the error.

System Details

Windows 11
Chrome 109.0.5414.122

@aoneill01 aoneill01 changed the title JS TypeError when clicking a procedure in the toolbox [ENA-266] JS TypeError when clicking a procedure in the toolbox Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants