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

Semiautovivification with a concat assignment produces an erroneous code #1028

Closed
pepkin88 opened this Issue Mar 26, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@pepkin88
Contributor

pepkin88 commented Mar 26, 2018

Example:

a[]b ++= [1 2]

Result:

a.b || (a.b = []) = (a.b = []).concat([1, 2]);

Expected result:

a.b = (a.b || (a.b = [])).concat([1, 2]);

The current behavior produces a code, which gives a runtime error ReferenceError: Invalid left-hand side in assignment.


The "expected result" block is a result of compiling:
(after merging #1026)

a.b = a[]b ++ [1 2]

which is a simplification of (currently uncompilable):

a[]b = a[]b ++ [1 2]

because the effects of semiautovivification are canceled by an assign.

@pepkin88 pepkin88 changed the title from Semiautovivification with a concat assignment produces erroneous code to Semiautovivification with a concat assignment produces an erroneous code Mar 26, 2018

@pepkin88

This comment has been minimized.

Contributor

pepkin88 commented Mar 26, 2018

The issue also applies to other assignments, but this one has a practical use case.

@determin1st

This comment has been minimized.

determin1st commented Mar 26, 2018

that's the craziest syntax i've ever seen 8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment