Skip to content

[Bug] Incrementing pitch number fails before any note is played #8326

Description

@macayu17

Description

Using add 1 to with the pitch number block before the turtle has played a note fails.

MyPitchBlock.setter() assumes tur.singer.lastNotePlayed exists, but it is null before the first note. The setter then tries to read lastNotePlayed[1].

Expected Behavior

The pitch number should initialize and increment successfully even when no note has been played yet.

Screenshots

Not applicable.

How to Reproduce

A source-level reproduction is currently confirmed:

  1. Set tur.singer.lastNotePlayed to null.
  2. Invoke MyPitchBlock.setter().

The setter accesses tur.singer.lastNotePlayed[1] and throws.

Console log Errors

TypeError: Cannot read properties of null (reading '1')
    at MyPitchBlock.setter

Environment

  • Browser: Google Chrome 151
  • Node.js: v22.22.3
  • Version of Software/Project: current master (b48c67a)

Checklist

  • I have read and followed the project's code of conduct.
  • I have searched for similar issues before creating this one.
  • I have provided all the necessary information to understand and reproduce the issue.
  • I am willing to contribute to the resolution of this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugFixes a bug or incorrect behavior

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions