Skip to content

Commit a73f66b

Browse files
2.2.1 (#4885)
* 2.2.1 changelog * Bump version to 2.2.1 and update output
1 parent ba09412 commit a73f66b

File tree

21 files changed

+96
-31
lines changed

21 files changed

+96
-31
lines changed

docs/v2/annotated-source/nodes.html

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,7 +2947,11 @@ <h3 id="range">Range</h3>
29472947
idx = del o, <span class="hljs-string">'index'</span>
29482948
idxName = del o, <span class="hljs-string">'name'</span>
29492949
namedIndex = idxName <span class="hljs-keyword">and</span> idxName <span class="hljs-keyword">isnt</span> idx
2950-
varPart = <span class="hljs-string">"<span class="hljs-subst">#{idx}</span> = <span class="hljs-subst">#{@fromC}</span>"</span>
2950+
varPart =
2951+
<span class="hljs-keyword">if</span> known <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> namedIndex
2952+
<span class="hljs-string">"var <span class="hljs-subst">#{idx}</span> = <span class="hljs-subst">#{@fromC}</span>"</span>
2953+
<span class="hljs-keyword">else</span>
2954+
<span class="hljs-string">"<span class="hljs-subst">#{idx}</span> = <span class="hljs-subst">#{@fromC}</span>"</span>
29512955
varPart += <span class="hljs-string">", <span class="hljs-subst">#{@toC}</span>"</span> <span class="hljs-keyword">if</span> @toC <span class="hljs-keyword">isnt</span> @toVar
29522956
varPart += <span class="hljs-string">", <span class="hljs-subst">#{@step}</span>"</span> <span class="hljs-keyword">if</span> @step <span class="hljs-keyword">isnt</span> @stepVar
29532957
[lt, gt] = [<span class="hljs-string">"<span class="hljs-subst">#{idx}</span> &lt;<span class="hljs-subst">#{@equals}</span>"</span>, <span class="hljs-string">"<span class="hljs-subst">#{idx}</span> &gt;<span class="hljs-subst">#{@equals}</span>"</span>]</pre></div></div>
@@ -4955,8 +4959,8 @@ <h3 id="assign">Assign</h3>
49554959

49564960
<div class="content"><div class='highlight'><pre> objects[splatsAndExpans.sort()[<span class="hljs-number">1</span>]].error <span class="hljs-string">"multiple splats/expansions are disallowed in an assignment"</span>
49574961

4958-
isSplat = splats.length
4959-
isExpans = expans.length
4962+
isSplat = splats?.length &gt; <span class="hljs-number">0</span>
4963+
isExpans = expans?.length &gt; <span class="hljs-number">0</span>
49604964
isObject = @variable.isObject()
49614965
isArray = @variable.isArray()
49624966

@@ -5101,7 +5105,7 @@ <h3 id="assign">Assign</h3>
51015105

51025106
</div>
51035107

5104-
<div class="content"><div class='highlight'><pre><span class="hljs-function"> <span class="hljs-title">loopObjects</span> = <span class="hljs-params">(objs, vvarTxt)</span> =&gt;</span>
5108+
<div class="content"><div class='highlight'><pre><span class="hljs-function"> <span class="hljs-title">loopObjects</span> = <span class="hljs-params">(objs, vvar, vvarTxt)</span> =&gt;</span>
51055109
objSpreads = hasObjSpreads objs
51065110
<span class="hljs-keyword">for</span> obj, i <span class="hljs-keyword">in</span> objs</pre></div></div>
51075111

@@ -5182,16 +5186,16 @@ <h3 id="assign">Assign</h3>
51825186

51835187
</div>
51845188

5185-
<div class="content"><div class='highlight'><pre><span class="hljs-function"> <span class="hljs-title">assignObjects</span> = <span class="hljs-params">(objs, vvarTxt)</span> =&gt;</span>
5189+
<div class="content"><div class='highlight'><pre><span class="hljs-function"> <span class="hljs-title">assignObjects</span> = <span class="hljs-params">(objs, vvar, vvarTxt)</span> =&gt;</span>
51865190
vvar = <span class="hljs-keyword">new</span> Value <span class="hljs-keyword">new</span> Arr(objs, <span class="hljs-literal">yes</span>)
51875191
vval = <span class="hljs-keyword">if</span> vvarTxt <span class="hljs-keyword">instanceof</span> Value <span class="hljs-keyword">then</span> vvarTxt <span class="hljs-keyword">else</span> <span class="hljs-keyword">new</span> Value <span class="hljs-keyword">new</span> Literal(vvarTxt)
51885192
assigns.push <span class="hljs-keyword">new</span> Assign(vvar, vval, <span class="hljs-literal">null</span>, param: @param, subpattern: <span class="hljs-literal">yes</span>).compileToFragments o, LEVEL_LIST
51895193
<span class="hljs-function">
5190-
<span class="hljs-title">processObjects</span> = <span class="hljs-params">(objs, vvarTxt)</span> -&gt;</span>
5194+
<span class="hljs-title">processObjects</span> = <span class="hljs-params">(objs, vvar, vvarTxt)</span> -&gt;</span>
51915195
<span class="hljs-keyword">if</span> complexObjects objs
5192-
loopObjects objs, vvarTxt
5196+
loopObjects objs, vvar, vvarTxt
51935197
<span class="hljs-keyword">else</span>
5194-
assignObjects objs, vvarTxt</pre></div></div>
5198+
assignObjects objs, vvar, vvarTxt</pre></div></div>
51955199

51965200
</li>
51975201

@@ -5220,7 +5224,7 @@ <h3 id="assign">Assign</h3>
52205224
expIdx = splatsAndExpans[<span class="hljs-number">0</span>]
52215225
leftObjs = objects.slice <span class="hljs-number">0</span>, expIdx + (<span class="hljs-keyword">if</span> isSplat <span class="hljs-keyword">then</span> <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> <span class="hljs-number">0</span>)
52225226
rightObjs = objects.slice expIdx + <span class="hljs-number">1</span>
5223-
processObjects leftObjs, vvarText <span class="hljs-keyword">if</span> leftObjs.length <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span>
5227+
processObjects leftObjs, vvar, vvarText <span class="hljs-keyword">if</span> leftObjs.length <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span>
52245228
<span class="hljs-keyword">if</span> rightObjs.length <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span></pre></div></div>
52255229

52265230
</li>
@@ -5243,7 +5247,7 @@ <h3 id="assign">Assign</h3>
52435247
restVar = refExp
52445248
refExp = o.scope.freeVariable <span class="hljs-string">'ref'</span>
52455249
assigns.push [@makeCode(refExp + <span class="hljs-string">' = '</span>), restVar.compileToFragments(o, LEVEL_LIST)...]
5246-
processObjects rightObjs, refExp
5250+
processObjects rightObjs, vvar, refExp
52475251
<span class="hljs-keyword">else</span></pre></div></div>
52485252

52495253
</li>
@@ -5259,7 +5263,7 @@ <h3 id="assign">Assign</h3>
52595263

52605264
</div>
52615265

5262-
<div class="content"><div class='highlight'><pre> processObjects objects, vvarText
5266+
<div class="content"><div class='highlight'><pre> processObjects objects, vvar, vvarText
52635267
assigns.push vvar <span class="hljs-keyword">unless</span> top <span class="hljs-keyword">or</span> @subpattern
52645268
fragments = @joinFragmentArrays assigns, <span class="hljs-string">', '</span>
52655269
<span class="hljs-keyword">if</span> o.level &lt; LEVEL_LIST <span class="hljs-keyword">then</span> fragments <span class="hljs-keyword">else</span> @wrapInParentheses fragments</pre></div></div>

docs/v2/browser-compiler/coffeescript.js

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

docs/v2/index.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@
646646
<section id="overview">
647647
<p><strong>CoffeeScript is a little language that compiles into JavaScript.</strong> Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.</p>
648648
<p>The golden rule of CoffeeScript is: <em>“It’s just JavaScript.”</em> The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. You can use any existing JavaScript library seamlessly from CoffeeScript (and vice-versa). The compiled output is readable, pretty-printed, and tends to run as fast or faster than the equivalent handwritten JavaScript.</p>
649-
<p><strong>Latest Version:</strong> <a href="https://github.com/jashkenas/coffeescript/tarball/2.2.0">2.2.0</a></p>
649+
<p><strong>Latest Version:</strong> <a href="https://github.com/jashkenas/coffeescript/tarball/2.2.1">2.2.1</a></p>
650650
<blockquote class="uneditable-code-block"><pre><code class="language-bash"><span class="comment"># Install locally for a project:</span>
651651
npm install --save-dev coffeescript
652652

@@ -4790,7 +4790,7 @@ <h2>Web Chat (IRC)</h2>
47904790
</section>
47914791
<section id="annotated-source">
47924792
<h2>Annotated Source</h2>
4793-
<p>You can browse the CoffeeScript 2.2.0 source in readable, annotated form <a href="annotated-source/">here</a>. You can also jump directly to a particular source file:</p>
4793+
<p>You can browse the CoffeeScript 2.2.1 source in readable, annotated form <a href="annotated-source/">here</a>. You can also jump directly to a particular source file:</p>
47944794
<ul>
47954795
<li><a href="annotated-source/grammar.html">Grammar Rules — src/grammar</a></li>
47964796
<li><a href="annotated-source/lexer.html">Lexing Tokens — src/lexer</a></li>
@@ -5467,6 +5467,14 @@ <h3>Argument parsing and shebang (<code>#!</code>) lines</h3>
54675467
</section>
54685468
<section id="changelog">
54695469
<h2>Changelog</h2>
5470+
<div class="anchor" id="2.2.1"></div>
5471+
<h2 class="header">
5472+
<a href="https://github.com/jashkenas/coffeescript/compare/2.1.0...2.2.1">2.2.1</a>
5473+
<span class="timestamp"> &mdash; <time datetime="2018-02-06">February 6, 2018</time></span>
5474+
</h2><ul>
5475+
<li>Bugfix for regression in 2.2.0 involving an error thrown by the compiler in certain cases when using destructuring with a splat or expansion in an array.</li>
5476+
<li>Bugfix for regression in 2.2.0 where in certain cases a range iterator variable was declared in the global scope.</li>
5477+
</ul>
54705478
<div class="anchor" id="2.2.0"></div>
54715479
<h2 class="header">
54725480
<a href="https://github.com/jashkenas/coffeescript/compare/2.1.1...2.2.0">2.2.0</a>

docs/v2/test.html

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,46 @@ <h1>CoffeeScript Test Suite</h1>
15731573
{{g}...} = g: 1
15741574
eq g, 1
15751575

1576+
test "#4878: Compile error when using destructuring with a splat or expansion in an array", ->
1577+
arr = ['a', 'b', 'c', 'd']
1578+
1579+
f1 = (list) ->
1580+
[first, ..., last] = list
1581+
1582+
f2 = (list) ->
1583+
[first..., last] = list
1584+
1585+
f3 = (list) ->
1586+
([first, ...] = list); first
1587+
1588+
f4 = (list) ->
1589+
([first, ...rest] = list); rest
1590+
1591+
arrayEq f1(arr), arr
1592+
arrayEq f2(arr), arr
1593+
arrayEq f3(arr), 'a'
1594+
arrayEq f4(arr), ['b', 'c', 'd']
1595+
1596+
foo = (list) ->
1597+
ret =
1598+
if list?.length > 0
1599+
[first, ..., last] = list
1600+
[first, last]
1601+
else
1602+
[]
1603+
1604+
arrayEq foo(arr), ['a', 'd']
1605+
1606+
bar = (list) ->
1607+
ret =
1608+
if list?.length > 0
1609+
[first, ...rest] = list
1610+
[first, rest]
1611+
else
1612+
[]
1613+
1614+
arrayEq bar(arr), ['a', ['b', 'c', 'd']]
1615+
15761616
</script>
15771617
<script type="text/x-coffeescript" class="test" id="async">
15781618
# Functions that contain the `await` keyword will compile into async functions,
@@ -16173,6 +16213,13 @@ <h2>Another heading</h2>
1617316213
r = (x for x in [b..a] by step)
1617416214
arrayEq r, []
1617516215

16216+
test "#4884: Range not declaring var for the 'i'", ->
16217+
'use strict'
16218+
[0..21].forEach (idx) ->
16219+
idx + 1
16220+
16221+
eq global.i, undefined
16222+
1617616223
</script>
1617716224
<script type="text/x-coffeescript" class="test" id="regexps">
1617816225
# Regular Expression Literals

documentation/sections/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## Changelog
22

3+
```
4+
releaseHeader('2018-02-06', '2.2.1', '2.1.0')
5+
```
6+
* Bugfix for regression in 2.2.0 involving an error thrown by the compiler in certain cases when using destructuring with a splat or expansion in an array.
7+
* Bugfix for regression in 2.2.0 where in certain cases a range iterator variable was declared in the global scope.
8+
39
```
410
releaseHeader('2018-02-01', '2.2.0', '2.1.1')
511
```

lib/coffeescript/browser.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/cake.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/coffeescript.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/command.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/grammar.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.

0 commit comments

Comments
 (0)