Simon Lydell
a46978640b
Allow variables named like helper functions
2015-01-11 12:12:40 +01:00
Simon Lydell
8ab15d7372
Fix #1500 , #1574 , #3318 : Name generated vars uniquely
...
Any variables generated by CoffeeScript are now made sure to be named to
something not present in the source code being compiled. This way you can no
longer interfere with them, either on purpose or by mistake. (#1500 , #1574 )
For example, `({a}, _arg) ->` now compiles correctly. (#1574 )
As opposed to the somewhat complex implementations discussed in #1500 , this
commit takes a very simple approach by saving all used variables names using a
single pass over the token stream. Any generated variables are then made sure
not to exist in that list.
`(@a) -> a` used to be equivalent to `(@a) -> @a`, but now throws a runtime
`ReferenceError` instead (unless `a` exists in an upper scope of course). (#3318 )
`(@a) ->` used to compile to `(function(a) { this.a = a; })`. Now it compiles to
`(function(_at_a) { this.a = _at_a; })`. (But you cannot access `_at_a` either,
of course.)
Because of the above, `(@a, a) ->` is now valid; `@a` and `a` are not duplicate
parameters.
Duplicate this-parameters with a reserved word, such as `(@case, @case) ->`,
used to compile but now throws, just like regular duplicate parameters.
2015-01-10 23:25:01 +01:00
xixixao
369e0545c0
Added expansion to destructuring
2014-01-24 16:00:34 +00:00
Marc Häfner
4cc2c305a4
Fixes #2181 -- conditional assignment as subexpression
...
* Parenthesize compilation of `||=` and `&&=` (when needed).
* Fix variable caching for `?=`
2013-10-20 22:59:01 +02:00
Jeremy Ashkenas
0b1d4d374a
Adding a test for #2613
2013-02-01 22:07:19 +11:00
Jez Ng
847ab4d18e
Parse compound assignment followed by a terminator.
...
Closes #2532 .
2012-11-27 20:11:01 -05:00
Gerald Lewis
f1b286469a
Wraps up #2211 -- addresses invocations within destructured params
2012-05-02 18:03:32 -04:00
Jeremy Ashkenas
0fada5109a
Merge pull request #2213 from geraldalewis/2211-destructed-splats
...
Issue #2211 -- splats in destructured parameters
2012-04-23 09:00:22 -07:00
Jeremy Ashkenas
f0e17fc20f
fixing compound assignments to global variables. oof.
2012-04-10 17:07:38 -04:00
Gerald Lewis
c5737764b5
Issue #2211 -- splats in destructured parameters
2012-03-23 13:20:15 -04:00
Jeremy Ashkenas
1c8411f628
merging in early error for compound assignment to undeclared variables.
2012-02-28 10:42:11 -05:00
Michael Ficarra
7c56da26f6
fixes #2055 : destructuring assignment with new
2012-01-18 23:12:50 -05:00
Jeremy Banks
3484ca5e64
Merge remote-tracking branch 'jashkenas/master' into fix-conditional-assignment
...
Conflicts:
test/assignment.coffee
2012-01-03 03:09:46 -05:00
Michael Ficarra
46b34d4b43
whitespace cleanup
2011-12-24 07:04:34 -05:00
Jeremy Ashkenas
686ef9e7f4
Fixes #1838
2011-12-14 18:31:20 -05:00
Jeremy Banks
a768f167cf
Improved tests for #1627 .
2011-10-04 22:26:50 -04:00
Jeremy Banks
03a8340a85
Add tests for conditional assignment of variable in parent scope.
2011-09-23 00:45:33 -04:00
Jeremy Banks
036197fac3
Prohibiting conditional assignment of undefined variables for #1627 .
2011-09-23 00:45:33 -04:00
Gerald Lewis
34f99c4a79
#1643 : Bugfix in heredoc in test for 1643
2011-09-09 21:30:00 -04:00
Gerald Lewis
7d4e693d20
#1643 : Updated tests
2011-09-09 18:59:35 -04:00
Gerald Lewis
8ebda7ac02
tests for #1643 : splatted accesses in destructuring assignments no longer create obj.key var declarations
2011-09-01 14:47:30 -04:00
Gerald Lewis
3a6c8c92b3
tests for #1591 : splatted expressions in destructuring assignment must be assignable
2011-08-30 11:12:39 -04:00
Michael Ficarra
fa2fbf0c60
minor enhancements to tests for #1005
2011-08-11 02:17:48 -04:00
Michael Ficarra
df5aca9348
fixes #1005 : invalid identifiers allowed on LHS of destructuring
...
assignment
2011-08-11 01:11:33 -04:00
Gerald Lewis
bd8d82809b
Updated tests for #1216 and pull #1348
2011-05-11 09:11:41 -04:00
Michael Ficarra
6c9ef76b95
fixed behavioural change accidentally introduced by #1348 , thanks @satyr
2011-05-11 00:08:24 -04:00
Michael Ficarra
a024ec5b27
reverting tests from @geraldalewis's fix for #1216
2011-05-10 23:23:31 -04:00
Gerald Lewis
2212e959ac
Fix for #1216 ?= compilation
2011-05-10 19:33:30 -04:00
Jann Horn
e84e703211
fixes bug mentioned by @satyr in #1108
...
"[v] = a ? b" must compile to
v = (typeof a != "undefined" && a !== null ? a : b)[0];
and not to:
v = typeof a != "undefined" && a !== null ? a : b[0];
2011-03-27 21:22:09 +02:00
Jeremy Ashkenas
d30c125ab7
continuing with the ol' refactorTests
2011-03-11 21:55:26 -05:00
Jeremy Ashkenas
9e2c75b548
removing over-hash-comment
2011-03-11 21:41:12 -05:00
Jeremy Ashkenas
44355f8eef
Issue #1024 .
2011-01-10 23:09:21 -05:00
Michael Ficarra
6421c865f5
finished reorganizing test suite
2011-01-03 04:17:00 -05:00
Michael Ficarra
fb201976b8
test reorganization waypoint #2
2010-12-29 14:06:57 -05:00
Michael Ficarra
dcfdd144d8
test reorganization waypoint
2010-12-29 00:48:54 -05:00
Michael Ficarra
0fd3ed593c
adding new (empty) classifications for tests
2010-12-28 23:33:13 -05:00
Michael Ficarra
8087a5914c
coffee-script/test$ for file in .; do git mv "$file" "_$file"; done
2010-12-28 18:07:15 -05:00
Jeremy Ashkenas
b9c2236885
Merging in MichaelFicarra's refactorTests branch.
2010-12-11 20:30:48 -05:00
Michael Ficarra
113cecc4f0
updated all completed test files except comments.coffee to the new
...
testing mini-framework
2010-12-10 00:23:37 -05:00
Michael Ficarra
049df99afc
consistency: eq(expected,actual), formatting, etc.
2010-12-07 22:04:16 -05:00
Michael Ficarra
cf45da33f6
refactored test_assignment.coffee
2010-12-03 18:21:09 -05:00