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

Semiautovivification with a concat assignment produces an erroneous code #1028

Closed
pepkin88 opened this issue Mar 26, 2018 · 2 comments
Closed
Assignees
Labels

Comments

@pepkin88
Copy link
Contributor

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 Semiautovivification with a concat assignment produces erroneous code Semiautovivification with a concat assignment produces an erroneous code Mar 26, 2018
@pepkin88
Copy link
Contributor Author

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

@determin1st
Copy link

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
Labels
Projects
None yet
Development

No branches or pull requests

3 participants