Skip to content

Commit

Permalink
2.2.2 (#4986)
Browse files Browse the repository at this point in the history
* Changelog for 2.2.2

* Bump version to 2.2.2

* Bump dependencies

* Update output
  • Loading branch information
GeoffreyBooth authored Feb 22, 2018
1 parent 72ab6fe commit e0833c2
Showing 23 changed files with 760 additions and 641 deletions.
8 changes: 4 additions & 4 deletions docs/v2/annotated-source/lexer.html
Original file line number Diff line number Diff line change
@@ -920,10 +920,10 @@ <h2 id="tokenizers">Tokenizers</h2>
indent = match[<span class="hljs-number">0</span>]

prev = @prev()
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>
backslash = prev?[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'\\'</span>
@seenFor = <span class="hljs-literal">no</span> <span class="hljs-keyword">unless</span> backslash <span class="hljs-keyword">and</span> @seenFor
@seenImport = <span class="hljs-literal">no</span> <span class="hljs-keyword">unless</span> @importSpecifierList
@seenExport = <span class="hljs-literal">no</span> <span class="hljs-keyword">unless</span> @exportSpecifierList
@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
@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

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

<span class="hljs-keyword">if</span> size &gt; @indent
<span class="hljs-keyword">if</span> noNewlines
@indebt = size - @indent
@indebt = size - @indent <span class="hljs-keyword">unless</span> backslash
@suppressNewlines()
<span class="hljs-keyword">return</span> indent.length
<span class="hljs-keyword">unless</span> @tokens.length
891 changes: 417 additions & 474 deletions docs/v2/annotated-source/nodes.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/v2/browser-compiler/coffeescript.js

Large diffs are not rendered by default.

24 changes: 16 additions & 8 deletions docs/v2/index.html
Original file line number Diff line number Diff line change
@@ -646,7 +646,7 @@
<section id="overview">
<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>
<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>
<p><strong>Latest Version:</strong> <a href="https://github.com/jashkenas/coffeescript/tarball/2.2.1">2.2.1</a></p>
<p><strong>Latest Version:</strong> <a href="https://github.com/jashkenas/coffeescript/tarball/2.2.2">2.2.2</a></p>
<blockquote class="uneditable-code-block"><pre><code class="language-bash"><span class="comment"># Install locally for a project:</span>
npm install --save-dev coffeescript

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

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

<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>) {
<span class="cm-keyword">var</span> <span class="cm-def">i</span>, <span class="cm-def">j</span>, <span class="cm-def">ref</span>;
<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>) {
<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>) {
<span class="cm-variable">say</span>(<span class="cm-variable-2">i</span>);
<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>
}
@@ -4524,7 +4524,7 @@ <h2>JSX</h2>
{(function() {
var i, ref, results;
results = [];
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) {
for (wholeStar = i = 0, ref = Math.floor(rating); (0 <= ref ? i < ref : i > ref); wholeStar = 0 <= ref ? ++i : --i) {
results.push(<Star className="wholeStar" key={wholeStar} />);
}
return results;
@@ -4533,7 +4533,7 @@ <h2>JSX</h2>
{(function() {
var i, ref, ref1, results;
results = [];
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) {
for (emptyStar = i = ref = Math.ceil(rating), ref1 = maxStars; (ref <= ref1 ? i < ref1 : i > ref1); emptyStar = ref <= ref1 ? ++i : --i) {
results.push(<Star className="emptyStar" key={emptyStar} />);
}
return results;
@@ -4549,7 +4549,7 @@ <h2>JSX</h2>
<span class="cm-string-2">{(function() {</span>
<span class="cm-string-2">var i, ref, results;</span>
<span class="cm-string-2">results = [];</span>
<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>
<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>
<span class="cm-string-2">results.push(&lt;Star className="wholeStar" key={wholeStar} />);</span>
<span class="cm-string-2">}</span>
<span class="cm-string-2">return results;</span>
@@ -4558,7 +4558,7 @@ <h2>JSX</h2>
<span class="cm-string-2">{(function() {</span>
<span class="cm-string-2">var i, ref, ref1, results;</span>
<span class="cm-string-2">results = [];</span>
<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>
<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>
<span class="cm-string-2">results.push(&lt;Star className="emptyStar" key={emptyStar} />);</span>
<span class="cm-string-2">}</span>
<span class="cm-string-2">return results;</span>
@@ -4790,7 +4790,7 @@ <h2>Web Chat (IRC)</h2>
</section>
<section id="annotated-source">
<h2>Annotated Source</h2>
<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>
<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>
<ul>
<li><a href="annotated-source/grammar.html">Grammar Rules — src/grammar</a></li>
<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>
</section>
<section id="changelog">
<h2>Changelog</h2>
<div class="anchor" id="2.2.2"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/2.1.1...2.2.2">2.2.2</a>
<span class="timestamp"> &mdash; <time datetime="2018-02-21">February 21, 2018</time></span>
</h2><ul>
<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>
<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>
</ul>
<div class="anchor" id="2.2.1"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/2.1.0...2.2.1">2.2.1</a>
196 changes: 178 additions & 18 deletions docs/v2/test.html
Original file line number Diff line number Diff line change
@@ -6937,6 +6937,59 @@ <h1>CoffeeScript Test Suite</h1>
}
'''

test "#4898: Lexer: backslash line continuation is inconsistent", ->
if ( \
false \
or \
true \
)
a = 42

eq a, 42

if ( \
false \
or \
true \
)
b = 42

eq b, 42

if ( \
false \
or \
true \
)
c = 42

eq c, 42

if \
false \
or \
true
d = 42

eq d, 42

if \
false or \
true
e = 42

eq e, 42

if \
false or \
true \
then \
f = 42 \
else
f = 24

eq f, 42

</script>
<script type="text/x-coffeescript" class="test" id="csx">
# We usually do not check the actual JS output from the compiler, but since
@@ -14369,6 +14422,73 @@ <h2>Another heading</h2>
from('foo');
"""

# Issue #4874: Backslash not supported in import or export statements
test "#4874: backslash `import`", ->

eqJS """
import foo \
from 'lib'

foo a
""",
"""
import foo from 'lib';

foo(a);
"""

eqJS """
import \
foo \
from \
'lib'

foo a
""",
"""
import foo from 'lib';

foo(a);
"""

eqJS """
import \
utilityBelt \
, {
each
} from \
'underscore'
""",
"""
import utilityBelt, {
each
} from 'underscore';
"""

test "#4874: backslash `export`", ->
eqJS """
export \
* \
from \
'underscore'
""",
"""
export * from 'underscore';
"""

eqJS """
export \
{ max, min } \
from \
'underscore'
""",
"""
export {
max,
min
} from 'underscore';
"""

</script>
<script type="text/x-coffeescript" class="test" id="numbers">
# Number Literals
@@ -16147,43 +16267,43 @@ <h2>Another heading</h2>

testData = [
[1, 5, 1, [1..5]]
[1, 5, -1, [1]]
[1, 5, -1, []]
[1, 5, up, [1..5]]
[1, 5, down, [1]]
[1, 5, down, []]

[a, 5, 1, [1..5]]
[a, 5, -1, [1]]
[a, 5, -1, []]
[a, 5, up, [1..5]]
[a, 5, down, [1]]
[a, 5, down, []]

[1, b, 1, [1..5]]
[1, b, -1, [1]]
[1, b, -1, []]
[1, b, up, [1..5]]
[1, b, down, [1]]
[1, b, down, []]

[a, b, 1, [1..5]]
[a, b, -1, [1]]
[a, b, -1, []]
[a, b, up, [1..5]]
[a, b, down, [1]]
[a, b, down, []]

[5, 1, 1, [5]]
[5, 1, 1, []]
[5, 1, -1, [5..1]]
[5, 1, up, [5]]
[5, 1, up, []]
[5, 1, down, [5..1]]

[5, a, 1, [5]]
[5, a, 1, []]
[5, a, -1, [5..1]]
[5, a, up, [5]]
[5, a, up, []]
[5, a, down, [5..1]]

[b, 1, 1, [5]]
[b, 1, 1, []]
[b, 1, -1, [5..1]]
[b, 1, up, [5]]
[b, 1, up, []]
[b, 1, down, [5..1]]

[b, a, 1, [5]]
[b, a, 1, []]
[b, a, -1, [5..1]]
[b, a, up, [5]]
[b, a, up, []]
[b, a, down, [5..1]]
]

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

r = (x for x in [a..b] by down)
arrayEq r, [1]
arrayEq r, []

r = (x for x in [b..a] by up)
arrayEq r, [5]
arrayEq r, []

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

eq global.i, undefined

test "#4889: `for` loop unexpected behavior", ->
n = 1
result = []
for i in [0..n]
result.push i
for j in [(i+1)..n]
result.push j

arrayEq result, [0,1,1,2,1]

test "#4889: `for` loop unexpected behavior with `by 1` on second loop", ->
n = 1
result = []
for i in [0..n]
result.push i
for j in [(i+1)..n] by 1
result.push j

arrayEq result, [0,1,1]

test "countdown example from docs", ->
countdown = (num for num in [10..1])
arrayEq countdown, [10,9,8,7,6,5,4,3,2,1]

test "counting up when the range goes down returns an empty array", ->
countdown = (num for num in [10..1] by 1)
arrayEq countdown, []

test "counting down when the range goes up returns an empty array", ->
countup = (num for num in [1..10] by -1)
arrayEq countup, []

test "counting down by too much returns just the first value", ->
countdown = (num for num in [10..1] by -100)
arrayEq countdown, [10]

test "counting up by too much returns just the first value", ->
countup = (num for num in [1..10] by 100)
arrayEq countup, [1]

</script>
<script type="text/x-coffeescript" class="test" id="regexps">
# Regular Expression Literals
6 changes: 6 additions & 0 deletions documentation/sections/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Changelog

```
releaseHeader('2018-02-21', '2.2.2', '2.1.1')
```
* 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).
* Bugfixes for allowing backslashes in `import` and `export` statements and lines that trigger the start of an indented block, like an `if` statement.

```
releaseHeader('2018-02-06', '2.2.1', '2.1.0')
```
2 changes: 1 addition & 1 deletion lib/coffeescript/browser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/coffeescript/cake.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/coffeescript/coffeescript.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/coffeescript/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e0833c2

Please sign in to comment.