Skip to content

Commit e0833c2

Browse files
2.2.2 (#4986)
* Changelog for 2.2.2 * Bump version to 2.2.2 * Bump dependencies * Update output
1 parent 72ab6fe commit e0833c2

File tree

23 files changed

+760
-641
lines changed

23 files changed

+760
-641
lines changed

docs/v2/annotated-source/lexer.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,10 @@ <h2 id="tokenizers">Tokenizers</h2>
920920
indent = match[<span class="hljs-number">0</span>]
921921

922922
prev = @prev()
923-
backslash = prev? <span class="hljs-keyword">and</span> prev[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'\\'</span>
923+
backslash = prev?[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'\\'</span>
924924
@seenFor = <span class="hljs-literal">no</span> <span class="hljs-keyword">unless</span> backslash <span class="hljs-keyword">and</span> @seenFor
925-
@seenImport = <span class="hljs-literal">no</span> <span class="hljs-keyword">unless</span> @importSpecifierList
926-
@seenExport = <span class="hljs-literal">no</span> <span class="hljs-keyword">unless</span> @exportSpecifierList
925+
@seenImport = <span class="hljs-literal">no</span> <span class="hljs-keyword">unless</span> (backslash <span class="hljs-keyword">and</span> @seenImport) <span class="hljs-keyword">or</span> @importSpecifierList
926+
@seenExport = <span class="hljs-literal">no</span> <span class="hljs-keyword">unless</span> (backslash <span class="hljs-keyword">and</span> @seenExport) <span class="hljs-keyword">or</span> @exportSpecifierList
927927

928928
size = indent.length - <span class="hljs-number">1</span> - indent.lastIndexOf <span class="hljs-string">'\n'</span>
929929
noNewlines = @unfinished()
@@ -944,7 +944,7 @@ <h2 id="tokenizers">Tokenizers</h2>
944944

945945
<span class="hljs-keyword">if</span> size &gt; @indent
946946
<span class="hljs-keyword">if</span> noNewlines
947-
@indebt = size - @indent
947+
@indebt = size - @indent <span class="hljs-keyword">unless</span> backslash
948948
@suppressNewlines()
949949
<span class="hljs-keyword">return</span> indent.length
950950
<span class="hljs-keyword">unless</span> @tokens.length

docs/v2/annotated-source/nodes.html

Lines changed: 417 additions & 474 deletions
Large diffs are not rendered by default.

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: 16 additions & 8 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.1">2.2.1</a></p>
649+
<p><strong>Latest Version:</strong> <a href="https://github.com/jashkenas/coffeescript/tarball/2.2.2">2.2.2</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

@@ -3504,7 +3504,7 @@ <h2>Async Functions</h2>
35043504

35053505
countdown = async function(seconds) {
35063506
var i, j, ref;
3507-
for (i = j = ref = seconds; undefined !== 0 && (ref <= 1 ? ref <= j && j <= 1 : ref >= j && j >= 1); i = ref <= 1 ? ++j : --j) {
3507+
for (i = j = ref = seconds; (ref <= 1 ? j <= 1 : j >= 1); i = ref <= 1 ? ++j : --j) {
35083508
say(i);
35093509
await sleep(1000); // wait one second
35103510
}
@@ -3530,7 +3530,7 @@ <h2>Async Functions</h2>
35303530

35313531
<span class="cm-variable">countdown</span> <span class="cm-operator">=</span> <span class="cm-keyword">async</span> <span class="cm-keyword">function</span>(<span class="cm-def">seconds</span>) {
35323532
<span class="cm-keyword">var</span> <span class="cm-def">i</span>, <span class="cm-def">j</span>, <span class="cm-def">ref</span>;
3533-
<span class="cm-keyword">for</span> (<span class="cm-variable-2">i</span> <span class="cm-operator">=</span> <span class="cm-variable-2">j</span> <span class="cm-operator">=</span> <span class="cm-variable-2">ref</span> <span class="cm-operator">=</span> <span class="cm-variable-2">seconds</span>; <span class="cm-atom">undefined</span> <span class="cm-operator">!==</span> <span class="cm-number">0</span> <span class="cm-operator">&amp;&amp;</span> (<span class="cm-variable-2">ref</span> <span class="cm-operator">&lt;=</span> <span class="cm-number">1</span> <span class="cm-operator">?</span> <span class="cm-variable-2">ref</span> <span class="cm-operator">&lt;=</span> <span class="cm-variable-2">j</span> <span class="cm-operator">&amp;&amp;</span> <span class="cm-variable-2">j</span> <span class="cm-operator">&lt;=</span> <span class="cm-number">1</span> : <span class="cm-variable-2">ref</span> <span class="cm-operator">>=</span> <span class="cm-variable-2">j</span> <span class="cm-operator">&amp;&amp;</span> <span class="cm-variable-2">j</span> <span class="cm-operator">>=</span> <span class="cm-number">1</span>); <span class="cm-variable-2">i</span> <span class="cm-operator">=</span> <span class="cm-variable-2">ref</span> <span class="cm-operator">&lt;=</span> <span class="cm-number">1</span> <span class="cm-operator">?</span> <span class="cm-operator">++</span><span class="cm-variable-2">j</span> : <span class="cm-operator">--</span><span class="cm-variable-2">j</span>) {
3533+
<span class="cm-keyword">for</span> (<span class="cm-variable-2">i</span> <span class="cm-operator">=</span> <span class="cm-variable-2">j</span> <span class="cm-operator">=</span> <span class="cm-variable-2">ref</span> <span class="cm-operator">=</span> <span class="cm-variable-2">seconds</span>; (<span class="cm-variable-2">ref</span> <span class="cm-operator">&lt;=</span> <span class="cm-number">1</span> <span class="cm-operator">?</span> <span class="cm-variable-2">j</span> <span class="cm-operator">&lt;=</span> <span class="cm-number">1</span> : <span class="cm-variable-2">j</span> <span class="cm-operator">>=</span> <span class="cm-number">1</span>); <span class="cm-variable-2">i</span> <span class="cm-operator">=</span> <span class="cm-variable-2">ref</span> <span class="cm-operator">&lt;=</span> <span class="cm-number">1</span> <span class="cm-operator">?</span> <span class="cm-operator">++</span><span class="cm-variable-2">j</span> : <span class="cm-operator">--</span><span class="cm-variable-2">j</span>) {
35343534
<span class="cm-variable">say</span>(<span class="cm-variable-2">i</span>);
35353535
<span class="cm-keyword">await</span> <span class="cm-variable">sleep</span>(<span class="cm-number">1000</span>); <span class="cm-comment">// wait one second</span>
35363536
}
@@ -4524,7 +4524,7 @@ <h2>JSX</h2>
45244524
{(function() {
45254525
var i, ref, results;
45264526
results = [];
4527-
for (wholeStar = i = 0, ref = Math.floor(rating); undefined !== 0 && (0 <= ref ? 0 <= i && i < ref : 0 >= i && i > ref); wholeStar = 0 <= ref ? ++i : --i) {
4527+
for (wholeStar = i = 0, ref = Math.floor(rating); (0 <= ref ? i < ref : i > ref); wholeStar = 0 <= ref ? ++i : --i) {
45284528
results.push(<Star className="wholeStar" key={wholeStar} />);
45294529
}
45304530
return results;
@@ -4533,7 +4533,7 @@ <h2>JSX</h2>
45334533
{(function() {
45344534
var i, ref, ref1, results;
45354535
results = [];
4536-
for (emptyStar = i = ref = Math.ceil(rating), ref1 = maxStars; undefined !== 0 && (ref <= ref1 ? ref <= i && i < ref1 : ref >= i && i > ref1); emptyStar = ref <= ref1 ? ++i : --i) {
4536+
for (emptyStar = i = ref = Math.ceil(rating), ref1 = maxStars; (ref <= ref1 ? i < ref1 : i > ref1); emptyStar = ref <= ref1 ? ++i : --i) {
45374537
results.push(<Star className="emptyStar" key={emptyStar} />);
45384538
}
45394539
return results;
@@ -4549,7 +4549,7 @@ <h2>JSX</h2>
45494549
<span class="cm-string-2">{(function() {</span>
45504550
<span class="cm-string-2">var i, ref, results;</span>
45514551
<span class="cm-string-2">results = [];</span>
4552-
<span class="cm-string-2">for (wholeStar = i = 0, ref = Math.floor(rating); undefined !== 0 &amp;&amp; (0 &lt;= ref ? 0 &lt;= i &amp;&amp; i &lt; ref : 0 >= i &amp;&amp; i > ref); wholeStar = 0 &lt;= ref ? ++i : --i) {</span>
4552+
<span class="cm-string-2">for (wholeStar = i = 0, ref = Math.floor(rating); (0 &lt;= ref ? i &lt; ref : i > ref); wholeStar = 0 &lt;= ref ? ++i : --i) {</span>
45534553
<span class="cm-string-2">results.push(&lt;Star className="wholeStar" key={wholeStar} />);</span>
45544554
<span class="cm-string-2">}</span>
45554555
<span class="cm-string-2">return results;</span>
@@ -4558,7 +4558,7 @@ <h2>JSX</h2>
45584558
<span class="cm-string-2">{(function() {</span>
45594559
<span class="cm-string-2">var i, ref, ref1, results;</span>
45604560
<span class="cm-string-2">results = [];</span>
4561-
<span class="cm-string-2">for (emptyStar = i = ref = Math.ceil(rating), ref1 = maxStars; undefined !== 0 &amp;&amp; (ref &lt;= ref1 ? ref &lt;= i &amp;&amp; i &lt; ref1 : ref >= i &amp;&amp; i > ref1); emptyStar = ref &lt;= ref1 ? ++i : --i) {</span>
4561+
<span class="cm-string-2">for (emptyStar = i = ref = Math.ceil(rating), ref1 = maxStars; (ref &lt;= ref1 ? i &lt; ref1 : i > ref1); emptyStar = ref &lt;= ref1 ? ++i : --i) {</span>
45624562
<span class="cm-string-2">results.push(&lt;Star className="emptyStar" key={emptyStar} />);</span>
45634563
<span class="cm-string-2">}</span>
45644564
<span class="cm-string-2">return results;</span>
@@ -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.1 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.2 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.2"></div>
5471+
<h2 class="header">
5472+
<a href="https://github.com/jashkenas/coffeescript/compare/2.1.1...2.2.2">2.2.2</a>
5473+
<span class="timestamp"> &mdash; <time datetime="2018-02-21">February 21, 2018</time></span>
5474+
</h2><ul>
5475+
<li>Bugfix for regression in 2.2.0 where a range with a <code>by</code> (step) value that increments or decrements in the opposite direction as the range was returning an array containing the first value of the range, whereas it should be returning an empty array. In other words, <code>x for x in [2..1] by 1</code> should equal <code>[]</code>, not <code>[2]</code> (because the step value is positive 1, counting up, whereas the range goes from 2 to 1, counting down).</li>
5476+
<li>Bugfixes for allowing backslashes in <code>import</code> and <code>export</code> statements and lines that trigger the start of an indented block, like an <code>if</code> statement.</li>
5477+
</ul>
54705478
<div class="anchor" id="2.2.1"></div>
54715479
<h2 class="header">
54725480
<a href="https://github.com/jashkenas/coffeescript/compare/2.1.0...2.2.1">2.2.1</a>

docs/v2/test.html

Lines changed: 178 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6937,6 +6937,59 @@ <h1>CoffeeScript Test Suite</h1>
69376937
}
69386938
'''
69396939

6940+
test "#4898: Lexer: backslash line continuation is inconsistent", ->
6941+
if ( \
6942+
false \
6943+
or \
6944+
true \
6945+
)
6946+
a = 42
6947+
6948+
eq a, 42
6949+
6950+
if ( \
6951+
false \
6952+
or \
6953+
true \
6954+
)
6955+
b = 42
6956+
6957+
eq b, 42
6958+
6959+
if ( \
6960+
false \
6961+
or \
6962+
true \
6963+
)
6964+
c = 42
6965+
6966+
eq c, 42
6967+
6968+
if \
6969+
false \
6970+
or \
6971+
true
6972+
d = 42
6973+
6974+
eq d, 42
6975+
6976+
if \
6977+
false or \
6978+
true
6979+
e = 42
6980+
6981+
eq e, 42
6982+
6983+
if \
6984+
false or \
6985+
true \
6986+
then \
6987+
f = 42 \
6988+
else
6989+
f = 24
6990+
6991+
eq f, 42
6992+
69406993
</script>
69416994
<script type="text/x-coffeescript" class="test" id="csx">
69426995
# We usually do not check the actual JS output from the compiler, but since
@@ -14369,6 +14422,73 @@ <h2>Another heading</h2>
1436914422
from('foo');
1437014423
"""
1437114424

14425+
# Issue #4874: Backslash not supported in import or export statements
14426+
test "#4874: backslash `import`", ->
14427+
14428+
eqJS """
14429+
import foo \
14430+
from 'lib'
14431+
14432+
foo a
14433+
""",
14434+
"""
14435+
import foo from 'lib';
14436+
14437+
foo(a);
14438+
"""
14439+
14440+
eqJS """
14441+
import \
14442+
foo \
14443+
from \
14444+
'lib'
14445+
14446+
foo a
14447+
""",
14448+
"""
14449+
import foo from 'lib';
14450+
14451+
foo(a);
14452+
"""
14453+
14454+
eqJS """
14455+
import \
14456+
utilityBelt \
14457+
, {
14458+
each
14459+
} from \
14460+
'underscore'
14461+
""",
14462+
"""
14463+
import utilityBelt, {
14464+
each
14465+
} from 'underscore';
14466+
"""
14467+
14468+
test "#4874: backslash `export`", ->
14469+
eqJS """
14470+
export \
14471+
* \
14472+
from \
14473+
'underscore'
14474+
""",
14475+
"""
14476+
export * from 'underscore';
14477+
"""
14478+
14479+
eqJS """
14480+
export \
14481+
{ max, min } \
14482+
from \
14483+
'underscore'
14484+
""",
14485+
"""
14486+
export {
14487+
max,
14488+
min
14489+
} from 'underscore';
14490+
"""
14491+
1437214492
</script>
1437314493
<script type="text/x-coffeescript" class="test" id="numbers">
1437414494
# Number Literals
@@ -16147,43 +16267,43 @@ <h2>Another heading</h2>
1614716267

1614816268
testData = [
1614916269
[1, 5, 1, [1..5]]
16150-
[1, 5, -1, [1]]
16270+
[1, 5, -1, []]
1615116271
[1, 5, up, [1..5]]
16152-
[1, 5, down, [1]]
16272+
[1, 5, down, []]
1615316273

1615416274
[a, 5, 1, [1..5]]
16155-
[a, 5, -1, [1]]
16275+
[a, 5, -1, []]
1615616276
[a, 5, up, [1..5]]
16157-
[a, 5, down, [1]]
16277+
[a, 5, down, []]
1615816278

1615916279
[1, b, 1, [1..5]]
16160-
[1, b, -1, [1]]
16280+
[1, b, -1, []]
1616116281
[1, b, up, [1..5]]
16162-
[1, b, down, [1]]
16282+
[1, b, down, []]
1616316283

1616416284
[a, b, 1, [1..5]]
16165-
[a, b, -1, [1]]
16285+
[a, b, -1, []]
1616616286
[a, b, up, [1..5]]
16167-
[a, b, down, [1]]
16287+
[a, b, down, []]
1616816288

16169-
[5, 1, 1, [5]]
16289+
[5, 1, 1, []]
1617016290
[5, 1, -1, [5..1]]
16171-
[5, 1, up, [5]]
16291+
[5, 1, up, []]
1617216292
[5, 1, down, [5..1]]
1617316293

16174-
[5, a, 1, [5]]
16294+
[5, a, 1, []]
1617516295
[5, a, -1, [5..1]]
16176-
[5, a, up, [5]]
16296+
[5, a, up, []]
1617716297
[5, a, down, [5..1]]
1617816298

16179-
[b, 1, 1, [5]]
16299+
[b, 1, 1, []]
1618016300
[b, 1, -1, [5..1]]
16181-
[b, 1, up, [5]]
16301+
[b, 1, up, []]
1618216302
[b, 1, down, [5..1]]
1618316303

16184-
[b, a, 1, [5]]
16304+
[b, a, 1, []]
1618516305
[b, a, -1, [5..1]]
16186-
[b, a, up, [5]]
16306+
[b, a, up, []]
1618716307
[b, a, down, [5..1]]
1618816308
]
1618916309

@@ -16199,10 +16319,10 @@ <h2>Another heading</h2>
1619916319
arrayEq r, [1..5]
1620016320

1620116321
r = (x for x in [a..b] by down)
16202-
arrayEq r, [1]
16322+
arrayEq r, []
1620316323

1620416324
r = (x for x in [b..a] by up)
16205-
arrayEq r, [5]
16325+
arrayEq r, []
1620616326

1620716327
r = (x for x in [b..a] by down)
1620816328
arrayEq r, [5..1]
@@ -16220,6 +16340,46 @@ <h2>Another heading</h2>
1622016340

1622116341
eq global.i, undefined
1622216342

16343+
test "#4889: `for` loop unexpected behavior", ->
16344+
n = 1
16345+
result = []
16346+
for i in [0..n]
16347+
result.push i
16348+
for j in [(i+1)..n]
16349+
result.push j
16350+
16351+
arrayEq result, [0,1,1,2,1]
16352+
16353+
test "#4889: `for` loop unexpected behavior with `by 1` on second loop", ->
16354+
n = 1
16355+
result = []
16356+
for i in [0..n]
16357+
result.push i
16358+
for j in [(i+1)..n] by 1
16359+
result.push j
16360+
16361+
arrayEq result, [0,1,1]
16362+
16363+
test "countdown example from docs", ->
16364+
countdown = (num for num in [10..1])
16365+
arrayEq countdown, [10,9,8,7,6,5,4,3,2,1]
16366+
16367+
test "counting up when the range goes down returns an empty array", ->
16368+
countdown = (num for num in [10..1] by 1)
16369+
arrayEq countdown, []
16370+
16371+
test "counting down when the range goes up returns an empty array", ->
16372+
countup = (num for num in [1..10] by -1)
16373+
arrayEq countup, []
16374+
16375+
test "counting down by too much returns just the first value", ->
16376+
countdown = (num for num in [10..1] by -100)
16377+
arrayEq countdown, [10]
16378+
16379+
test "counting up by too much returns just the first value", ->
16380+
countup = (num for num in [1..10] by 100)
16381+
arrayEq countup, [1]
16382+
1622316383
</script>
1622416384
<script type="text/x-coffeescript" class="test" id="regexps">
1622516385
# 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-21', '2.2.2', '2.1.1')
5+
```
6+
* Bugfix for regression in 2.2.0 where a range with a `by` (step) value that increments or decrements in the opposite direction as the range was returning an array containing the first value of the range, whereas it should be returning an empty array. In other words, `x for x in [2..1] by 1` should equal `[]`, not `[2]` (because the step value is positive 1, counting up, whereas the range goes from 2 to 1, counting down).
7+
* Bugfixes for allowing backslashes in `import` and `export` statements and lines that trigger the start of an indented block, like an `if` statement.
8+
39
```
410
releaseHeader('2018-02-06', '2.2.1', '2.1.0')
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.

0 commit comments

Comments
 (0)