Skip to content

Commit 41185ca

Browse files
helixbassGeoffreyBooth
authored andcommitted
Normalize :: syntax (#5048)
* normalize :: syntax * fixes from code review
1 parent 7dbdca8 commit 41185ca

File tree

7 files changed

+174
-149
lines changed

7 files changed

+174
-149
lines changed

lib/coffeescript/grammar.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/coffeescript/lexer.js

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

lib/coffeescript/parser.js

Lines changed: 151 additions & 147 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/grammar.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ grammar =
371371
o ':: Property', -> [LOC(1)(new Access new PropertyName('prototype')), LOC(2)(new Access $2)]
372372
o '?:: Property', -> [LOC(1)(new Access new PropertyName('prototype'), 'soak'), LOC(2)(new Access $2)]
373373
o '::', -> new Access new PropertyName 'prototype'
374+
o '?::', -> new Access new PropertyName('prototype'), 'soak'
374375
o 'Index'
375376
]
376377

src/lexer.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ POSSIBLY_DIVISION = /// ^ /=?\s ///
12931293
# Other regexes.
12941294
HERECOMMENT_ILLEGAL = /\*\//
12951295
1296-
LINE_CONTINUER = /// ^ \s* (?: , | \??\.(?![.\d]) | :: ) ///
1296+
LINE_CONTINUER = /// ^ \s* (?: , | \??\.(?![.\d]) | \??:: ) ///
12971297
12981298
STRING_INVALID_ESCAPE = ///
12991299
( (?:^|[^\\]) (?:\\\\)* ) # Make sure the escape isn’t escaped.

test/formatting.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ test "`?.` and `::` should continue lines", ->
7070
::
7171
?.foo
7272
)
73+
74+
ok not (
75+
Date
76+
?::
77+
?.foo
78+
)
7379
#eq Object::toString, Date?.
7480
#prototype
7581
#::

test/operators.coffee

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,16 @@ test "#2567: Optimization of negated existential produces correct result", ->
303303

304304
test "#2508: Existential access of the prototype", ->
305305
eq NonExistent?::nothing, undefined
306+
eq(
307+
NonExistent
308+
?::nothing
309+
undefined
310+
)
306311
ok Object?::toString
312+
ok(
313+
Object
314+
?::toString
315+
)
307316

308317
test "floor division operator", ->
309318
eq 2, 7 // 3

0 commit comments

Comments
 (0)