Skip to content

Handle strands set() calls in branches and loops#8576

Merged
davepagurek merged 1 commit intodev-2.0from
fix/strands-set-branch
Feb 28, 2026
Merged

Handle strands set() calls in branches and loops#8576
davepagurek merged 1 commit intodev-2.0from
fix/strands-set-branch

Conversation

@davepagurek
Copy link
Contributor

Resolves #8573

Changes:

  • So the problem here is that ifs and fors determine what updates each loop/branch based on parsing of = statements. But calling .set(...), a new construct, doesn't get noticed as part of that.
  • Rather than doing a refactor to handle = OR .set() calls in loops and branching, instead this transpiles away .set() calls in loops/branches to use an intermediate variable outside the loop, assign to it normally inside the loop, and then call .set() on the result at the end.
  • Also fixes an issue with let something; intermediate variables that don't have a type. Previously they worked only if you use them as a "flat" dependency, i.e. you assign them directly with a value. If you have a conditional update where you assign it to either itself or a real value, then we get a nested dependency, and it breaks. So now we recursively update types when you do that, so that all nested dependencies get type info.

Screenshots of the change:

Live: https://editor.p5js.org/davepagurek/sketches/iY_hzGaAj

PR Checklist

@davepagurek davepagurek merged commit dbf8367 into dev-2.0 Feb 28, 2026
5 checks passed
@davepagurek davepagurek deleted the fix/strands-set-branch branch February 28, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant