Skip to content

BF: Fix JS translation of .pop() when there's no index#6651

Merged
peircej merged 2 commits into
psychopy:devfrom
TEParsons:dev-bf-ast-parse
Jul 8, 2024
Merged

BF: Fix JS translation of .pop() when there's no index#6651
peircej merged 2 commits into
psychopy:devfrom
TEParsons:dev-bf-ast-parse

Conversation

@TEParsons
Copy link
Copy Markdown
Contributor

Current if you do:

a.pop()

you get

 a.splice((- 1), 1)

JS doesn't have negative indexing, so can't splice the -1st value. Instead, we should use <name>.length - 1, to give:

a.splice(a.length-1, 1)

@peircej peircej merged commit 5b1ac10 into psychopy:dev Jul 8, 2024
@peircej peircej added the 🐞 bug Issue describes a bug (crash or error) or undefined behavior. label Jul 19, 2024
@TEParsons TEParsons deleted the dev-bf-ast-parse branch July 24, 2024 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Issue describes a bug (crash or error) or undefined behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants