Skip to content

Commit 6456b4f

Browse files
committed
Merge remote-tracking branch 'upstream/main' into referenced-vars
2 parents 7b2bdf4 + 8d32c71 commit 6456b4f

34 files changed

+2330
-1728
lines changed

.github/workflows/continuous-integration.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ jobs:
1111
strategy:
1212
matrix:
1313
operating-system: [ubuntu-latest, macos-latest, windows-latest]
14-
node-version: [10.x, 12.x, 14.x, 16.x]
14+
node-version: [12.x, 14.x, 16.x, 17.x]
1515

1616
steps:
17-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v3
1818
- name: Use Node.js ${{ matrix.node-version }}
19-
uses: actions/setup-node@v2
19+
uses: actions/setup-node@v3
2020
with:
2121
node-version: ${{ matrix.node-version }}
22+
cache: 'npm'
2223

2324
- run: npm ci
2425

Cakefile

+22-34
Original file line numberDiff line numberDiff line change
@@ -499,17 +499,6 @@ task 'test', 'run the CoffeeScript language test suite', ->
499499

500500

501501
task 'test:browser', 'run the test suite against the modern browser compiler in a headless browser', ->
502-
# This test uses Puppeteer to launch headless Chrome to test the ES module
503-
# version of the browser compiler. There’s no reason to run this test in old
504-
# versions of Node (the runtime is the headless Chrome browser, not Node),
505-
# and Puppeteer 3 only supports Node >= 10.18.1, so limit this test to those
506-
# versions. The code below uses `Promise.prototype.finally` because the
507-
# CoffeeScript codebase currently maintains compatibility with Node 6, which
508-
# did not support `async`/`await` syntax. Even though this test doesn’t run
509-
# in Node 6, it needs to still _parse_ in Node 6 so that this file can load.
510-
[major, minor, build] = process.versions.node.split('.').map (n) -> parseInt(n, 10)
511-
return if major < 10 or (major is 10 and minor < 18) or (major is 10 and minor is 18 and build < 1)
512-
513502
# Create very simple web server to serve the two files we need.
514503
http = require 'http'
515504
serveFile = (res, fileToServe, mimeType) ->
@@ -526,29 +515,28 @@ task 'test:browser', 'run the test suite against the modern browser compiler in
526515
else
527516
res.statusCode = 404
528517
res.end()
529-
server.listen 8080
530-
531-
puppeteer = require 'puppeteer'
532-
browser = page = result = null
533-
puppeteer.launch()
534-
.then((browserHandle) ->
535-
browser = browserHandle
536-
browser.newPage()
537-
).then((pageHandle) ->
538-
page = pageHandle
539-
page.goto 'http://localhost:8080/'
540-
).then(->
541-
page.waitForSelector '#result',
542-
visible: yes
543-
polling: 'mutation'
544-
).then((element) ->
545-
page.evaluate ((el) => el.textContent), element
546-
).then((elementText) ->
547-
result = elementText
548-
).finally(->
549-
browser.close()
550-
).finally ->
551-
server.close()
518+
519+
server.listen 8080, ->
520+
puppeteer = require 'puppeteer'
521+
browser = await puppeteer.launch()
522+
page = await browser.newPage()
523+
result = ""
524+
525+
try
526+
await page.goto 'http://localhost:8080/'
527+
528+
element = await page.waitForSelector '#result',
529+
visible: yes
530+
polling: 'mutation'
531+
timeout: 60000
532+
533+
result = await page.evaluate ((el) => el.textContent), element
534+
catch e
535+
log e, red
536+
finally
537+
try browser.close()
538+
server.close()
539+
552540
if result and not result.includes('failed')
553541
log result, green
554542
else

docs/v2/annotated-source/grammar.html

+5-2
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ <h2 id="grammatical-rules">Grammatical Rules</h2>
372372
dollar-sign variables are provided by Jison as references to the value of
373373
their numeric position, so in this rule:</p>
374374
<pre><code><span class="hljs-string">&#x27;Expression UNLESS Expression&#x27;</span>
375-
</code></pre><p><code>$1</code> would be the value of the first <code>Expression</code>, <code>$2</code> would be the token
375+
</code></pre>
376+
<p><code>$1</code> would be the value of the first <code>Expression</code>, <code>$2</code> would be the token
376377
for the <code>UNLESS</code> terminal, and <code>$3</code> would be the value of the second
377378
<code>Expression</code>.</p>
378379

@@ -1975,9 +1976,11 @@ <h2 id="precedence">Precedence</h2>
19751976
<p>Operators at the top of this list have higher precedence than the ones lower
19761977
down. Following these rules is what makes <code>2 + 3 * 4</code> parse as:</p>
19771978
<pre><code><span class="hljs-number">2</span> + (<span class="hljs-number">3</span> * <span class="hljs-number">4</span>)
1978-
</code></pre><p>And not:</p>
1979+
</code></pre>
1980+
<p>And not:</p>
19791981
<pre><code>(<span class="hljs-number">2</span> + <span class="hljs-number">3</span>) * <span class="hljs-number">4</span>
19801982
</code></pre>
1983+
19811984
</div>
19821985

19831986
<div class="content"><div class='highlight'><pre>operators = [

docs/v2/annotated-source/lexer.html

+7-3
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ <h1>lexer.coffee</h1>
120120
a token is produced, we consume the match, and start again. Tokens are in the
121121
form:</p>
122122
<pre><code>[tag, value, locationData]
123-
</code></pre><p>where locationData is {first_line, first_column, last_line, last_column, last_line_exclusive, last_column_exclusive}, which is a
123+
</code></pre>
124+
<p>where locationData is {first_line, first_column, last_line, last_column, last_line_exclusive, last_column_exclusive}, which is a
124125
format that can be fed directly into <a href="https://github.com/zaach/jison">Jison</a>. These
125126
are read by jison in the <code>parser.lexer</code> function defined in coffeescript.coffee.</p>
126127

@@ -974,7 +975,8 @@ <h2 id="tokenizers">Tokenizers</h2>
974975
<pre><code>elements
975976
.each( ... )
976977
.map( ... )
977-
</code></pre><p>Keeps track of the level of indentation, because a single outdent token
978+
</code></pre>
979+
<p>Keeps track of the level of indentation, because a single outdent token
978980
can close multiple indents, so we need to know how far in we happen to be.</p>
979981

980982
</div>
@@ -1590,7 +1592,8 @@ <h2 id="token-manipulators">Token Manipulators</h2>
15901592
inside it using Ruby-like notation for substitution of arbitrary
15911593
expressions.</p>
15921594
<pre><code><span class="hljs-string">&quot;Hello <span class="hljs-subst">#{name.capitalize()}</span>.&quot;</span>
1593-
</code></pre><p>If it encounters an interpolation, this method will recursively create a new
1595+
</code></pre>
1596+
<p>If it encounters an interpolation, this method will recursively create a new
15941597
Lexer and tokenize until the <code>{</code> of <code>#{</code> is balanced with a <code>}</code>.</p>
15951598
<ul>
15961599
<li><code>regex</code> matches the contents of a token (but not <code>delimiter</code>, and not
@@ -1941,6 +1944,7 @@ <h2 id="token-manipulators">Token Manipulators</h2>
19411944
<pre><code>el.click(<span class="hljs-function"><span class="hljs-params">(event)</span> -&gt;</span>
19421945
el.hide())
19431946
</code></pre>
1947+
19441948
</div>
19451949

19461950
<div class="content"><div class='highlight'><pre> [..., lastIndent] = @indents

docs/v2/annotated-source/nodes.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -3518,7 +3518,7 @@ <h3 id="jsx">JSX</h3>
35183518
<div class="sswrap ">
35193519
<a class="ss" href="#section-134">&#x00a7;</a>
35203520
</div>
3521-
<p>Catch invalid attributes: <div {a:"b", props} {props} "value" /></p>
3521+
<p>Catch invalid attributes: &lt;div {a:”b”, props} {props} value” /&gt;</p>
35223522

35233523
</div>
35243524

@@ -8727,6 +8727,7 @@ <h3 id="op">Op</h3>
87278727
<pre><code>bin/coffee -e <span class="hljs-string">&#x27;console.log 50 &lt; 65 &gt; 10&#x27;</span>
87288728
<span class="hljs-literal">true</span>
87298729
</code></pre>
8730+
87308731
</div>
87318732

87328733
<div class="content"><div class='highlight'><pre> compileChain: <span class="hljs-function"><span class="hljs-params">(o)</span> -&gt;</span>
@@ -10563,6 +10564,7 @@ <h2 id="helper-functions">Helper Functions</h2>
1056310564
mergeLocationData(first, second, justLeading: <span class="hljs-literal">yes</span>).range <span class="hljs-comment"># [1, 5]</span>
1056410565
mergeLocationData(first, second, justEnding: <span class="hljs-literal">yes</span>).range <span class="hljs-comment"># [4, 10]</span>
1056510566
</code></pre>
10567+
1056610568
</div>
1056710569

1056810570
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.mergeLocationData = mergeLocationData = <span class="hljs-function"><span class="hljs-params">(locationDataA, locationDataB, {justLeading, justEnding} = {})</span> -&gt;</span>
@@ -10629,6 +10631,7 @@ <h2 id="helper-functions">Helper Functions</h2>
1062910631
mergeAstLocationData(first, second, justLeading: <span class="hljs-literal">yes</span>).range <span class="hljs-comment"># [1, 5]</span>
1063010632
mergeAstLocationData(first, second, justEnding: <span class="hljs-literal">yes</span>).range <span class="hljs-comment"># [4, 10]</span>
1063110633
</code></pre>
10634+
1063210635
</div>
1063310636

1063410637
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.mergeAstLocationData = mergeAstLocationData = <span class="hljs-function"><span class="hljs-params">(nodeA, nodeB, {justLeading, justEnding} = {})</span> -&gt;</span>

docs/v2/annotated-source/optparse.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ <h1>optparse.coffee</h1>
133133
Use it like so:</p>
134134
<pre><code>parser = <span class="hljs-keyword">new</span> OptionParser switches, helpBanner
135135
options = parser.parse process.argv
136-
</code></pre><p>The first non-option is considered to be the start of the file (and file
136+
</code></pre>
137+
<p>The first non-option is considered to be the start of the file (and file
137138
option) list, and all subsequent arguments are left unparsed.</p>
138139
<p>The <code>coffee</code> command uses an instance of <strong>OptionParser</strong> to parse its
139140
command-line arguments in <code>src/command.coffee</code>.</p>
@@ -153,7 +154,8 @@ <h1>optparse.coffee</h1>
153154
</div>
154155
<p>Initialize with a list of valid options, in the form:</p>
155156
<pre><code>[short-flag, long-flag, description]
156-
</code></pre><p>Along with an optional banner for the usage help.</p>
157+
</code></pre>
158+
<p>Along with an optional banner for the usage help.</p>
157159

158160
</div>
159161

docs/v2/annotated-source/rewriter.html

+25-10
Original file line numberDiff line numberDiff line change
@@ -738,22 +738,28 @@ <h1>rewriter.coffee</h1>
738738
<pre><code>f
739739
a: b
740740
c: d
741-
</code></pre><p>Don’t accept implicit calls of this type, when on the same line
741+
</code></pre>
742+
<p>Don’t accept implicit calls of this type, when on the same line
742743
as the control structures below as that may misinterpret constructs like:</p>
743744
<pre><code><span class="hljs-keyword">if</span> f
744745
a: <span class="hljs-number">1</span>
745-
</code></pre><p>as</p>
746+
</code></pre>
747+
<p>as</p>
746748
<pre><code><span class="hljs-keyword">if</span> f(a: <span class="hljs-number">1</span>)
747-
</code></pre><p>which is probably always unintended.
748-
Furthermore don’t allow this in literal arrays, as
749-
that creates grammatical ambiguities.</p>
749+
</code></pre>
750+
<p>which is probably always unintended.
751+
Furthermore don’t allow this in the first line of a literal array
752+
or explicit object, as that creates grammatical ambiguities (#5368).</p>
750753

751754
</div>
752755

753756
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> tag <span class="hljs-keyword">in</span> IMPLICIT_FUNC <span class="hljs-keyword">and</span>
754757
@indexOfTag(i + <span class="hljs-number">1</span>, <span class="hljs-string">&#x27;INDENT&#x27;</span>) &gt; <span class="hljs-number">-1</span> <span class="hljs-keyword">and</span> @looksObjectish(i + <span class="hljs-number">2</span>) <span class="hljs-keyword">and</span>
755758
<span class="hljs-keyword">not</span> @findTagsBackwards(i, [<span class="hljs-string">&#x27;CLASS&#x27;</span>, <span class="hljs-string">&#x27;EXTENDS&#x27;</span>, <span class="hljs-string">&#x27;IF&#x27;</span>, <span class="hljs-string">&#x27;CATCH&#x27;</span>,
756-
<span class="hljs-string">&#x27;SWITCH&#x27;</span>, <span class="hljs-string">&#x27;LEADING_WHEN&#x27;</span>, <span class="hljs-string">&#x27;FOR&#x27;</span>, <span class="hljs-string">&#x27;WHILE&#x27;</span>, <span class="hljs-string">&#x27;UNTIL&#x27;</span>])
759+
<span class="hljs-string">&#x27;SWITCH&#x27;</span>, <span class="hljs-string">&#x27;LEADING_WHEN&#x27;</span>, <span class="hljs-string">&#x27;FOR&#x27;</span>, <span class="hljs-string">&#x27;WHILE&#x27;</span>, <span class="hljs-string">&#x27;UNTIL&#x27;</span>]) <span class="hljs-keyword">and</span>
760+
<span class="hljs-keyword">not</span> ((s = stackTop()?[<span class="hljs-number">0</span>]) <span class="hljs-keyword">in</span> [<span class="hljs-string">&#x27;{&#x27;</span>, <span class="hljs-string">&#x27;[&#x27;</span>] <span class="hljs-keyword">and</span>
761+
<span class="hljs-keyword">not</span> isImplicit(stackTop()) <span class="hljs-keyword">and</span>
762+
@findTagsBackwards(i, s))
757763
startImplicitCall i + <span class="hljs-number">1</span>
758764
stack.push [<span class="hljs-string">&#x27;INDENT&#x27;</span>, i + <span class="hljs-number">2</span>]
759765
<span class="hljs-keyword">return</span> forward(<span class="hljs-number">3</span>)</pre></div></div>
@@ -807,13 +813,18 @@ <h1>rewriter.coffee</h1>
807813
<div class="sswrap ">
808814
<a class="ss" href="#section-30">&#x00a7;</a>
809815
</div>
810-
<p>Are we just continuing an already declared object?</p>
816+
<p>Are we just continuing an already declared object?
817+
Including the case where we indent on the line after an explicit ‘{‘.</p>
811818

812819
</div>
813820

814821
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> stackTop()
815822
[stackTag, stackIdx] = stackTop()
816-
<span class="hljs-keyword">if</span> (stackTag <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;{&#x27;</span> <span class="hljs-keyword">or</span> stackTag <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;INDENT&#x27;</span> <span class="hljs-keyword">and</span> @tag(stackIdx - <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;{&#x27;</span>) <span class="hljs-keyword">and</span>
823+
stackNext = stack[stack.length - <span class="hljs-number">2</span>]
824+
<span class="hljs-keyword">if</span> (stackTag <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;{&#x27;</span> <span class="hljs-keyword">or</span>
825+
stackTag <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;INDENT&#x27;</span> <span class="hljs-keyword">and</span> stackNext?[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;{&#x27;</span> <span class="hljs-keyword">and</span>
826+
<span class="hljs-keyword">not</span> isImplicit(stackNext) <span class="hljs-keyword">and</span>
827+
@findTagsBackwards(stackIdx<span class="hljs-number">-1</span>, [<span class="hljs-string">&#x27;{&#x27;</span>])) <span class="hljs-keyword">and</span>
817828
(startsLine <span class="hljs-keyword">or</span> @tag(s - <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;,&#x27;</span> <span class="hljs-keyword">or</span> @tag(s - <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;{&#x27;</span>) <span class="hljs-keyword">and</span>
818829
@tag(s - <span class="hljs-number">1</span>) <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> UNFINISHED
819830
<span class="hljs-keyword">return</span> forward(<span class="hljs-number">1</span>)
@@ -838,11 +849,13 @@ <h1>rewriter.coffee</h1>
838849
.g b, <span class="hljs-function">-&gt;</span>
839850
c
840851
.h a
841-
</code></pre><p>and also</p>
852+
</code></pre>
853+
<p>and also</p>
842854
<pre><code>f a
843855
.g b
844856
.h a
845857
</code></pre>
858+
846859
</div>
847860

848861
</li>
@@ -963,9 +976,11 @@ <h1>rewriter.coffee</h1>
963976
a: b,
964977
c: d,
965978
e = <span class="hljs-number">2</span>
966-
</code></pre><p>and</p>
979+
</code></pre>
980+
<p>and</p>
967981
<pre><code>f a, b: c, d: e, f, g: h: i, j
968982
</code></pre>
983+
969984
</div>
970985

971986
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;,&#x27;</span> <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> @looksObjectish(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">and</span> inImplicitObject() <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> (@tag(i + <span class="hljs-number">2</span>) <span class="hljs-keyword">in</span> [<span class="hljs-string">&#x27;FOROF&#x27;</span>, <span class="hljs-string">&#x27;FORIN&#x27;</span>]) <span class="hljs-keyword">and</span>

docs/v2/browser-compiler-legacy/coffeescript.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/v2/browser-compiler-modern/coffeescript.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)