Commit 31666c2
committed
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/37318021 parent b2e760c commit 31666c2
2 files changed
+48
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
75 | 101 | | |
76 | 102 | | |
77 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
656 | 656 | | |
657 | 657 | | |
658 | 658 | | |
659 | | - | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
660 | 662 | | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
665 | 667 | | |
666 | | - | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
667 | 682 | | |
668 | 683 | | |
669 | 684 | | |
| |||
0 commit comments