processing / processing/p5.js-web-editor

bug in loop protection macro expansion

Open
#4,183 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
JavaScript
Stars
1.7k
Forks
1.7k
Avg merge
3d 4h
Merged PRs (30d)
8

Description

p5.js version

1.11.11

What is your operating system?

Windows

Web browser and version

chrome 149.0.7827.104

Actual Behavior

"ReferenceError: _LP0 is not defined"

Expected Behavior

expected to run fine without errors.

Steps to reproduce

When run this code:
--- code begins --
//#つぶやきProcessing #p5js
t=0,h=.03
draw=_=>{
t||createCanvas(W=(w=200)2,W)+noStroke()+colorMode(HSB)
background(1,.1)
for(u=-4;u<4;u+=h)
for(i=0,x=u,y=u;i<t;i++)
[x,y]=[(x-y-x
(S=xx+yy))h+x,(x-y+yS)h+y],
rect(X=x
w+w,Y=yw+w,(fill(wcos(X-Y+t/17),w,w,.3),8))
t=++t%W}
--- code ends ---
Got this:
ReferenceError: LP0 is not defined
at /sketch.js:12:30
Instead, when run this code (with braces '{}')
--- code begins ---
//#つぶやきProcessing #p5js
t=0,h=.03
draw=
=>{
t||createCanvas(W=(w=200)2,W)+noStroke()+colorMode(HSB)
background(1,.1)
for(u=-4;u<4;u+=h)
{ // added
for(i=0,x=u,y=u;i<t;i++)
[x,y]=[(x-y-x
(S=xx+yy))h+x,(x-y+yS)h+y],
rect(X=x
w+w,Y=yw+w,(fill(wcos(X-Y+t/17),w,w,.3),8))
} // added
t=++t%W}
--- code ends ---
Runs fine.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with the provided p5.js sketch in the p5.js Editor, then inspect the loop-protection macro expansion that generates the _LP0 reference. Compare the failing loop without braces to the working braced version; done means the original sketch runs without a ReferenceError and does not require added braces.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.