forked from anko/eslisp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix macros' this.evaluate for object args
This supercedes my stupidity in be77679. as [raised in chat][1] by @terinjokes, passing a list `(object a 1)` to a macro and attempting to `this.evaluate` it caused unexpected results, and passing `(object a 1 b 2)` failed altogether. As mentioned, this was due to `eval` parsing "{ a: 1 }" as a block statement containing a labelled literal. [More detail on SO here][2]. The fix is to wrap the JS generated from ObjectExpression AST nodes in parentheses before evaluating it. As explained in the comments, we still want this.evaluate to be able to evaluate statements, so I added an if-branch for that and a test to cover it. [1]: https://gitter.im/anko/eslisp?at=566a7415cffd648a0554eeeb [2]: http://stackoverflow.com/questions/3731802
- Loading branch information
Showing
2 changed files
with
48 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters