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

PaperScript compiler produces invalid JavaScript (ReferenceError: invalid assignment left-hand side) #1151

nebaughman opened this issue Aug 28, 2016 · 2 comments


Copy link

@nebaughman nebaughman commented Aug 28, 2016

Version: Paper.js v0.10.2-develop

Problem: PaperScript compiler produces invalid JavaScript

This is valid JavaScript:

1 < a.count && (a.radius += 2.0);

PaperScript compiler (probably around PaperScript.js Line#255) turns this into invalid JavaScript:

1 < a.count && a.radius = __$__(a.radius, "+", 2.0);

Browser console shows this error:

ReferenceError: invalid assignment left-hand side

Workaround: Don't code this way.

Background: I discovered this after compiling some PaperScript code with ClosureCompiler, which minified this if-statement: if (a.count > 1) a.radius += 2.0; into 1 < a.count && (a.radius += 2.0);

Overall, supporting the offending syntax would make PaperScript code more compatible with ClosureCompiler, and avoid producing invalid JavaScript (in this otherwise rather esoteric case).

(PS Thanks for this fantastic library!)

Copy link

@lehni lehni commented Nov 21, 2016

Thanks for spotting this! It looks like the problem is that the parenthesis are being dropped, correct?

Copy link

@lehni lehni commented Nov 21, 2016

Here a sketch to reproduce the issue.

@lehni lehni closed this in d779789 Nov 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.