Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2d1addf

Browse files
committed
Allowget orset parentheses-less function calls when first argument is a string without a colon (so a plain string, not a property accessor)
1 parent962374a commit2d1addf

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

‎lib/coffeescript/lexer.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎src/lexer.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ exports.Lexer = class Lexer
252252
if prevand@value()is'from'and (@seenImportor@seenExport)
253253
prev[0]='FROM'
254254

255-
if prevandprev.spacedand prev[0]in CALLABLEand/^[gs]et$/.test(prev[1])
255+
if prevandprev.spacedand prev[0]in CALLABLEand/^[gs]et$/.test(prev[1])and/^\S*:\s/.test(@chunk)
256256
@error"'#{prev[1]}' cannot be used as a keyword, or as a function call without parentheses", prev[2]
257257

258258
regex=switch quote

‎test/function_invocation.coffee

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,15 +712,23 @@ test "get and set can be used as function names when not ambiguous with `get`/`s
712712
set= (val)-> val
713713
eq2,get(2)
714714
eq3,set(3)
715+
eq2,get2
716+
eq3,set3
715717
eq'a',get('a')
716718
eq'b',set('b')
719+
eq'a',get'a'
720+
eq'b',set'b'
717721

718722
get= ({val})-> val
719723
set= ({val})-> val
720724
eq4,get({val:4})
721725
eq5,set({val:5})
726+
eq4,get {val:4}
727+
eq5,set {val:5}
722728
eq'c',get({val:'c'})
723729
eq'd',set({val:'d'})
730+
eq'c',get {val:'c'}
731+
eq'd',set {val:'d'}
724732

725733
test"get and set can be used as variable and property names",->
726734
get=2

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp