Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Allow calling functions with a bang! #2289

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+18 −0
Split

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -181,6 +181,11 @@ class exports.Rewriter
seenControl = no
noCall = no if tag in LINEBREAKS
token.call = yes if prev and not prev.spaced and tag is '?'
+
+ if tag is 'UNARY' and token[1] is '!' and prev? and prev[0] is 'IDENTIFIER' and not prev.spaced
+ callObject = true
+ tokens.splice i, 1
+
return 1 if token.fromThen
return 1 unless callObject or
prev?.spaced and (prev.call or prev[0] in IMPLICIT_FUNC) and
@@ -550,3 +550,12 @@ test "#960: improved 'do'", ->
eq two, 2
func
eq ret, func
+
+test "bang calling a function", ->
+ class Foo
+ bar: -> 3
@tswicegood

tswicegood Apr 26, 2012

The evil TDD me keeps thinking this means that bar! only returns a 3. :-)

+
+ foo = new Foo()
+
+ eq 3, foo.bar!
+