Compare commits

...

7 Commits
2.2.0 ... 2.2.2

Author SHA1 Message Date
Geoffrey Booth
e0833c29ce 2.2.2 (#4986)
* Changelog for 2.2.2

* Bump version to 2.2.2

* Bump dependencies

* Update output
2018-02-22 00:31:14 -08:00
zdenko
72ab6feb2f Fix #4889: for...range loop condition (#4891)
* fix #4889

* test

* move test from 'control_flow' to 'ranges'

* More range tests
2018-02-20 00:46:20 -08:00
zdenko
eb7009268d fix #4898 (#4899) 2018-02-17 16:57:49 -08:00
zdenko
571e9df335 fix #4874 (#4888) 2018-02-08 21:11:11 -08:00
Geoffrey Booth
a73f66bc11 2.2.1 (#4885)
* 2.2.1 changelog

* Bump version to 2.2.1 and update output
2018-02-06 22:28:15 -08:00
zdenko
ba094126e2 Fix #4882: Range not declaring var for the "i" (#4883)
* fix #4882

* test
2018-02-04 13:33:08 -08:00
zdenko
794f65fbd7 Fix #4878: Compile error when using destructuring with a splat or expansion in an array (#4879)
* fix #4878

* improvements

* test

* refactor
2018-02-03 13:35:41 -08:00
29 changed files with 1114 additions and 723 deletions

View File

@@ -920,10 +920,10 @@ can close multiple indents, so we need to know how far in we happen to be.</p>
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 @@ can close multiple indents, so we need to know how far in we happen to be.</p>
<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

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -646,7 +646,7 @@ div.CodeMirror-cursor {
<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>“Its 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.0">2.2.0</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 @@ say = function(text) {
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 @@ countdown(3);
<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 @@ renderStarRating = function({rating, maxStars}) {
{(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 @@ renderStarRating = function({rating, maxStars}) {
{(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 @@ renderStarRating = function({rating, maxStars}) {
<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 @@ renderStarRating = function({rating, maxStars}) {
<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 @@ The CoffeeScript logo is available in SVG for use in presentations.</li>
</section>
<section id="annotated-source">
<h2>Annotated Source</h2>
<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>
<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,22 @@ x = <span class="number">2</span> + <span class="number">2</span>
</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>
<span class="timestamp"> &mdash; <time datetime="2018-02-06">February 6, 2018</time></span>
</h2><ul>
<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>
<li>Bugfix for regression in 2.2.0 where in certain cases a range iterator variable was declared in the global scope.</li>
</ul>
<div class="anchor" id="2.2.0"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/2.1.1...2.2.0">2.2.0</a>

View File

@@ -1573,6 +1573,46 @@ test "#4673: complex destructured object spread variables", ->
{{g}...} = g: 1
eq g, 1
test "#4878: Compile error when using destructuring with a splat or expansion in an array", ->
arr = ['a', 'b', 'c', 'd']
f1 = (list) ->
[first, ..., last] = list
f2 = (list) ->
[first..., last] = list
f3 = (list) ->
([first, ...] = list); first
f4 = (list) ->
([first, ...rest] = list); rest
arrayEq f1(arr), arr
arrayEq f2(arr), arr
arrayEq f3(arr), 'a'
arrayEq f4(arr), ['b', 'c', 'd']
foo = (list) ->
ret =
if list?.length > 0
[first, ..., last] = list
[first, last]
else
[]
arrayEq foo(arr), ['a', 'd']
bar = (list) ->
ret =
if list?.length > 0
[first, ...rest] = list
[first, rest]
else
[]
arrayEq bar(arr), ['a', ['b', 'c', 'd']]
</script>
<script type="text/x-coffeescript" class="test" id="async">
# Functions that contain the `await` keyword will compile into async functions,
@@ -6897,6 +6937,59 @@ test "#4871: `else if` no longer output together ", ->
}
'''
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
@@ -14329,6 +14422,73 @@ test "#4491: import- and export-specific lexing should stop after import/export
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
@@ -16107,43 +16267,43 @@ test "#2047: Infinite loop possible when `for` loop with `range` uses variables"
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]]
]
@@ -16159,10 +16319,10 @@ test "#2047: from, to and step as variables", ->
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]
@@ -16173,6 +16333,53 @@ test "#2047: from, to and step as variables", ->
r = (x for x in [b..a] by step)
arrayEq r, []
test "#4884: Range not declaring var for the 'i'", ->
'use strict'
[0..21].forEach (idx) ->
idx + 1
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

View File

@@ -1,5 +1,17 @@
## 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')
```
* 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.
* Bugfix for regression in 2.2.0 where in certain cases a range iterator variable was declared in the global scope.
```
releaseHeader('2018-02-01', '2.2.0', '2.1.1')
```

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.0
// Generated by CoffeeScript 2.2.2
(function() {
// This **Browser** compatibility layer extends core CoffeeScript functions
// to make things work smoothly when compiling code directly in the browser.

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.0
// Generated by CoffeeScript 2.2.2
(function() {
// `cake` is a simplified version of [Make](http://www.gnu.org/software/make/)
// ([Rake](http://rake.rubyforge.org/), [Jake](https://github.com/280north/jake))

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.0
// Generated by CoffeeScript 2.2.2
(function() {
// CoffeeScript can be used both on the server, as a command-line compiler based
// on Node.js/V8, or to run CoffeeScript directly in the browser. This module

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.0
// Generated by CoffeeScript 2.2.2
(function() {
// The `coffee` utility. Handles command-line compilation of CoffeeScript
// into various forms: saved into `.js` files or printed to stdout

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.0
// Generated by CoffeeScript 2.2.2
(function() {
// The CoffeeScript parser is generated by [Jison](https://github.com/zaach/jison)
// from this grammar file. Jison is a bottom-up parser generator, similar in

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.0
// Generated by CoffeeScript 2.2.2
(function() {
// This file contains the common helper functions that we'd like to share among
// the **Lexer**, **Rewriter**, and the **Nodes**. Merge objects, flatten

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.0
// Generated by CoffeeScript 2.2.2
(function() {
// Node.js Implementation
var CoffeeScript, ext, fs, helpers, i, len, path, ref, universalCompile, vm,

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.0
// Generated by CoffeeScript 2.2.2
(function() {
// The CoffeeScript Lexer. Uses a series of token-matching regexes to attempt
// matches against the beginning of the source code. When a match is found,
@@ -593,14 +593,14 @@
}
indent = match[0];
prev = this.prev();
backslash = (prev != null) && prev[0] === '\\';
backslash = (prev != null ? prev[0] : void 0) === '\\';
if (!(backslash && this.seenFor)) {
this.seenFor = false;
}
if (!this.importSpecifierList) {
if (!((backslash && this.seenImport) || this.importSpecifierList)) {
this.seenImport = false;
}
if (!this.exportSpecifierList) {
if (!((backslash && this.seenExport) || this.exportSpecifierList)) {
this.seenExport = false;
}
size = indent.length - 1 - indent.lastIndexOf('\n');
@@ -629,7 +629,9 @@
}
if (size > this.indent) {
if (noNewlines) {
this.indebt = size - this.indent;
if (!backslash) {
this.indebt = size - this.indent;
}
this.suppressNewlines();
return indent.length;
}

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.0
// Generated by CoffeeScript 2.2.2
(function() {
// `nodes.coffee` contains all of the node classes for the syntax tree. Most
// nodes are created as the result of actions in the [grammar](grammar.html),
@@ -2031,7 +2031,7 @@
// When compiled normally, the range returns the contents of the *for loop*
// needed to iterate over the values in the range. Used by comprehensions.
compileNode(o) {
var cond, condPart, from, gt, idx, idxName, known, lowerBound, lt, namedIndex, stepCond, stepPart, to, upperBound, varPart;
var cond, condPart, from, gt, idx, idxName, known, lowerBound, lt, namedIndex, ref1, ref2, stepCond, stepNotZero, stepPart, to, upperBound, varPart;
if (!this.fromVar) {
this.compileVariables(o);
}
@@ -2043,7 +2043,7 @@
idx = del(o, 'index');
idxName = del(o, 'name');
namedIndex = idxName && idxName !== idx;
varPart = `${idx} = ${this.fromC}`;
varPart = known && !namedIndex ? `var ${idx} = ${this.fromC}` : `${idx} = ${this.fromC}`;
if (this.toC !== this.toVar) {
varPart += `, ${this.toC}`;
}
@@ -2054,12 +2054,11 @@
// Generate the condition.
[from, to] = [this.fromNum, this.toNum];
// Always check if the `step` isn't zero to avoid the infinite loop.
stepCond = this.stepNum ? `${this.stepNum} !== 0` : `${this.stepVar} !== 0`;
condPart = known ? this.step == null ? from <= to ? `${lt} ${to}` : `${gt} ${ // from < to
to}` : (lowerBound = `${from} <= ${idx} && ${lt} ${// from > to
to}`, upperBound = `${from} >= ${idx} && ${gt} ${to}`, from <= to ? `${stepCond} && ${lowerBound}` : `${stepCond} && ${// from < to
upperBound}`) : (lowerBound = `${this.fromVar} <= ${idx} && ${lt} ${// from > to
this.toVar}`, upperBound = `${this.fromVar} >= ${idx} && ${gt} ${this.toVar}`, `${stepCond} && (${this.fromVar} <= ${this.toVar} ? ${lowerBound} : ${upperBound})`);
stepNotZero = `${(ref1 = this.stepNum) != null ? ref1 : this.stepVar} !== 0`;
stepCond = `${(ref2 = this.stepNum) != null ? ref2 : this.stepVar} > 0`;
lowerBound = `${lt} ${(known ? to : this.toVar)}`;
upperBound = `${gt} ${(known ? to : this.toVar)}`;
condPart = this.step != null ? `${stepNotZero} && (${stepCond} ? ${lowerBound} : ${upperBound})` : known ? `${(from <= to ? lt : gt)} ${to}` : `(${this.fromVar} <= ${this.toVar} ? ${lowerBound} : ${upperBound})`;
cond = this.stepVar ? `${this.stepVar} > 0` : `${this.fromVar} <= ${this.toVar}`;
// Generate the step.
stepPart = this.stepVar ? `${idx} += ${this.stepVar}` : known ? namedIndex ? from <= to ? `++${idx}` : `--${idx}` : from <= to ? `${idx}++` : `${idx}--` : namedIndex ? `${cond} ? ++${idx} : --${idx}` : `${cond} ? ${idx}++ : ${idx}--`;
@@ -3575,8 +3574,8 @@ this.toVar}`, upperBound = `${this.fromVar} >= ${idx} && ${gt} ${this.toVar}`, `
// Sort 'splatsAndExpans' so we can show error at first disallowed token.
objects[splatsAndExpans.sort()[1]].error("multiple splats/expansions are disallowed in an assignment");
}
isSplat = splats.length;
isExpans = expans.length;
isSplat = (splats != null ? splats.length : void 0) > 0;
isExpans = (expans != null ? expans.length : void 0) > 0;
isObject = this.variable.isObject();
isArray = this.variable.isArray();
vvar = value.compileToFragments(o, LEVEL_LIST);
@@ -3648,7 +3647,7 @@ this.toVar}`, upperBound = `${this.fromVar} >= ${idx} && ${gt} ${this.toVar}`, `
};
// "Complex" `objects` are processed in a loop.
// Examples: [a, b, {c, r...}, d], [a, ..., {b, r...}, c, d]
loopObjects = (objs, vvarTxt) => {
loopObjects = (objs, vvar, vvarTxt) => {
var acc, idx, j, len1, message, objSpreads, results, vval;
objSpreads = hasObjSpreads(objs);
results = [];
@@ -3707,7 +3706,7 @@ this.toVar}`, upperBound = `${this.fromVar} >= ${idx} && ${gt} ${this.toVar}`, `
return results;
};
// "Simple" `objects` can be split and compiled to arrays, [a, b, c] = arr, [a, b, c...] = arr
assignObjects = (objs, vvarTxt) => {
assignObjects = (objs, vvar, vvarTxt) => {
var vval;
vvar = new Value(new Arr(objs, true));
vval = vvarTxt instanceof Value ? vvarTxt : new Value(new Literal(vvarTxt));
@@ -3716,11 +3715,11 @@ this.toVar}`, upperBound = `${this.fromVar} >= ${idx} && ${gt} ${this.toVar}`, `
subpattern: true
}).compileToFragments(o, LEVEL_LIST));
};
processObjects = function(objs, vvarTxt) {
processObjects = function(objs, vvar, vvarTxt) {
if (complexObjects(objs)) {
return loopObjects(objs, vvarTxt);
return loopObjects(objs, vvar, vvarTxt);
} else {
return assignObjects(objs, vvarTxt);
return assignObjects(objs, vvar, vvarTxt);
}
};
// In case there is `Splat` or `Expansion` in `objects`,
@@ -3739,7 +3738,7 @@ this.toVar}`, upperBound = `${this.fromVar} >= ${idx} && ${gt} ${this.toVar}`, `
leftObjs = objects.slice(0, expIdx + (isSplat ? 1 : 0));
rightObjs = objects.slice(expIdx + 1);
if (leftObjs.length !== 0) {
processObjects(leftObjs, vvarText);
processObjects(leftObjs, vvar, vvarText);
}
if (rightObjs.length !== 0) {
// Slice or splice `objects`.
@@ -3756,11 +3755,11 @@ this.toVar}`, upperBound = `${this.fromVar} >= ${idx} && ${gt} ${this.toVar}`, `
refExp = o.scope.freeVariable('ref');
assigns.push([this.makeCode(refExp + ' = '), ...restVar.compileToFragments(o, LEVEL_LIST)]);
}
processObjects(rightObjs, refExp);
processObjects(rightObjs, vvar, refExp);
}
} else {
// There is no `Splat` or `Expansion` in `objects`.
processObjects(objects, vvarText);
processObjects(objects, vvar, vvarText);
}
if (!(top || this.subpattern)) {
assigns.push(vvar);

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.0
// Generated by CoffeeScript 2.2.2
(function() {
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat,
splice = [].splice;

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.0
// Generated by CoffeeScript 2.2.2
(function() {
var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, getRootModule, helpers, i, len, loadFile, path, ref;

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.0
// Generated by CoffeeScript 2.2.2
(function() {
var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, replDefaults, runInContext, sawSIGINT, transpile, updateSyntaxError, vm;

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.0
// Generated by CoffeeScript 2.2.2
(function() {
// The CoffeeScript language has a good deal of optional syntax, implicit syntax,
// and shorthand syntax. This can greatly complicate a grammar and bloat
@@ -218,7 +218,7 @@
indexOfTag(i, ...pattern) {
var fuzz, j, k, ref, ref1;
fuzz = 0;
for (j = k = 0, ref = pattern.length; undefined !== 0 && (0 <= ref ? 0 <= k && k < ref : 0 >= k && k > ref); j = 0 <= ref ? ++k : --k) {
for (j = k = 0, ref = pattern.length; (0 <= ref ? k < ref : k > ref); j = 0 <= ref ? ++k : --k) {
if (pattern[j] == null) {
continue;
}

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.0
// Generated by CoffeeScript 2.2.2
(function() {
// The **Scope** class regulates lexical scoping within CoffeeScript. As you
// generate code, you create a tree of scopes in the same shape as the nested

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.0
// Generated by CoffeeScript 2.2.2
(function() {
// Source maps allow JavaScript runtimes to match running JavaScript back to
// the original source code that corresponds to it. This can be minified

232
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "coffeescript",
"version": "2.2.0",
"version": "2.2.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -17,9 +17,9 @@
"dev": true
},
"acorn": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.2.1.tgz",
"integrity": "sha512-jG0u7c4Ly+3QkkW18V+NRDN+4bWHdln30NL1ZL2AvFZZmQe/BfopYCtghCKKVBUSetZ4QKcyA0pY6/4Gw8Pv8w==",
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.4.1.tgz",
"integrity": "sha512-XLmq3H/BVvW6/GbxKryGxWORz1ebilSsUDlyC27bXhWGWAZWkGwS6FLHjOlwFXNFoWFQEO/Df4u0YYd0K3BQgQ==",
"dev": true
},
"acorn-dynamic-import": {
@@ -40,21 +40,20 @@
}
},
"ajv": {
"version": "5.5.1",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.1.tgz",
"integrity": "sha1-s4u4h22ehr7plJVqBOch6IskjrI=",
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.1.1.tgz",
"integrity": "sha1-l41Zf7wrfQ5aXD3esUmmgvKr+g4=",
"dev": true,
"requires": {
"co": "4.6.0",
"fast-deep-equal": "1.0.0",
"fast-json-stable-stringify": "2.0.0",
"json-schema-traverse": "0.3.1"
}
},
"ajv-keywords": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz",
"integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=",
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.1.0.tgz",
"integrity": "sha1-rCsnk5xUPpXSwG5/f1wnvkqlQ74=",
"dev": true
},
"align-text": {
@@ -98,9 +97,9 @@
}
},
"argparse": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz",
"integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=",
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"dev": true,
"requires": {
"sprintf-js": "1.0.3"
@@ -128,9 +127,9 @@
"dev": true
},
"asn1.js": {
"version": "4.9.2",
"resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.2.tgz",
"integrity": "sha512-b/OsSjvWEo8Pi8H0zsDd2P6Uqo2TK2pH8gNLSJtNLM2Db0v2QaAZ0pBQJXVjAn4gBuugeVDr7s63ZogpUIwWDg==",
"version": "4.10.1",
"resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz",
"integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==",
"dev": true,
"requires": {
"bn.js": "4.11.8",
@@ -1581,9 +1580,9 @@
"dev": true
},
"base64-js": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz",
"integrity": "sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw==",
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.3.tgz",
"integrity": "sha512-MsAhsUW1GxCdgYSO6tAfZrNapmUKk7mWx/k5mFY/A1gBtkaCaNapTg+FExCw1r9yeaZhqx/xPg43xgTFH6KL5w==",
"dev": true
},
"big.js": {
@@ -1674,7 +1673,7 @@
"dev": true,
"requires": {
"bn.js": "4.11.8",
"randombytes": "2.0.5"
"randombytes": "2.0.6"
}
},
"browserify-sign": {
@@ -1717,7 +1716,7 @@
"integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=",
"dev": true,
"requires": {
"base64-js": "1.2.1",
"base64-js": "1.2.3",
"ieee754": "1.1.8",
"isarray": "1.0.0"
}
@@ -1822,12 +1821,6 @@
"wordwrap": "0.0.2"
}
},
"co": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
"integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=",
"dev": true
},
"code-point-at": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
@@ -1835,9 +1828,9 @@
"dev": true
},
"codemirror": {
"version": "5.32.0",
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.32.0.tgz",
"integrity": "sha512-95OxAlYiigW0g4n4ixFdavG07clJGILp3MvHh2pKR3FvyrTuHHvqtKSVbrV3/Jz6o0YqGvyCDLDTbH4h6ciaSw==",
"version": "5.35.0",
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.35.0.tgz",
"integrity": "sha512-8HQICjZlDfe1ai7bvU6m2uHxuZuFgsUCdDRU9OHVB+2RTRd+FftN1ezVCqbquG0Fyq+wETqyadKhUX46DswSUQ==",
"dev": true
},
"colors": {
@@ -1910,7 +1903,7 @@
"cipher-base": "1.0.4",
"inherits": "2.0.3",
"ripemd160": "2.0.1",
"sha.js": "2.4.9"
"sha.js": "2.4.10"
}
},
"create-hmac": {
@@ -1924,7 +1917,7 @@
"inherits": "2.0.3",
"ripemd160": "2.0.1",
"safe-buffer": "5.1.1",
"sha.js": "2.4.9"
"sha.js": "2.4.10"
}
},
"cross-spawn": {
@@ -1953,8 +1946,8 @@
"inherits": "2.0.3",
"pbkdf2": "3.0.14",
"public-encrypt": "4.0.0",
"randombytes": "2.0.5",
"randomfill": "1.0.3"
"randombytes": "2.0.6",
"randomfill": "1.0.4"
}
},
"d": {
@@ -1963,7 +1956,7 @@
"integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=",
"dev": true,
"requires": {
"es5-ext": "0.10.37"
"es5-ext": "0.10.39"
}
},
"date-now": {
@@ -2014,7 +2007,7 @@
"requires": {
"bn.js": "4.11.8",
"miller-rabin": "4.0.1",
"randombytes": "2.0.5"
"randombytes": "2.0.6"
}
},
"docco": {
@@ -2031,9 +2024,9 @@
}
},
"domain-browser": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz",
"integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz",
"integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==",
"dev": true
},
"ebnf-parser": {
@@ -2088,12 +2081,12 @@
"dev": true
},
"errno": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.4.tgz",
"integrity": "sha1-uJbiOp5ei6M4cfyZar02NfyaHH0=",
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz",
"integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==",
"dev": true,
"requires": {
"prr": "0.0.0"
"prr": "1.0.1"
}
},
"error-ex": {
@@ -2106,9 +2099,9 @@
}
},
"es5-ext": {
"version": "0.10.37",
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.37.tgz",
"integrity": "sha1-DudB0Ui4AGm6J9AgOTdWryV978M=",
"version": "0.10.39",
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.39.tgz",
"integrity": "sha512-AlaXZhPHl0po/uxMx1tyrlt1O86M6D5iVaDH8UgLfgek4kXTX6vzsRfJQWC2Ku+aG8pkw1XWzh9eTkwfVrsD5g==",
"dev": true,
"requires": {
"es6-iterator": "2.0.3",
@@ -2122,7 +2115,7 @@
"dev": true,
"requires": {
"d": "1.0.0",
"es5-ext": "0.10.37",
"es5-ext": "0.10.39",
"es6-symbol": "3.1.1"
}
},
@@ -2133,7 +2126,7 @@
"dev": true,
"requires": {
"d": "1.0.0",
"es5-ext": "0.10.37",
"es5-ext": "0.10.39",
"es6-iterator": "2.0.3",
"es6-set": "0.1.5",
"es6-symbol": "3.1.1",
@@ -2147,7 +2140,7 @@
"dev": true,
"requires": {
"d": "1.0.0",
"es5-ext": "0.10.37",
"es5-ext": "0.10.39",
"es6-iterator": "2.0.3",
"es6-symbol": "3.1.1",
"event-emitter": "0.3.5"
@@ -2160,7 +2153,7 @@
"dev": true,
"requires": {
"d": "1.0.0",
"es5-ext": "0.10.37"
"es5-ext": "0.10.39"
}
},
"es6-weak-map": {
@@ -2170,7 +2163,7 @@
"dev": true,
"requires": {
"d": "1.0.0",
"es5-ext": "0.10.37",
"es5-ext": "0.10.39",
"es6-iterator": "2.0.3",
"es6-symbol": "3.1.1"
}
@@ -2274,7 +2267,7 @@
"dev": true,
"requires": {
"d": "1.0.0",
"es5-ext": "0.10.37"
"es5-ext": "0.10.39"
}
},
"events": {
@@ -3703,7 +3696,7 @@
"integrity": "sha1-2UpGSPmxwXnWT6lykSaL22zpQ08=",
"dev": true,
"requires": {
"uc.micro": "1.0.3"
"uc.micro": "1.0.5"
}
},
"load-json-file": {
@@ -3789,16 +3782,16 @@
}
},
"markdown-it": {
"version": "8.4.0",
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-8.4.0.tgz",
"integrity": "sha512-tNuOCCfunY5v5uhcO2AUMArvKAyKMygX8tfup/JrgnsDqcCATQsAExBq7o5Ml9iMmO82bk6jYNLj6khcrl0JGA==",
"version": "8.4.1",
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-8.4.1.tgz",
"integrity": "sha512-CzzqSSNkFRUf9vlWvhK1awpJreMRqdCrBvZ8DIoDWTOkESMIF741UPAhuAmbyWmdiFPA6WARNhnu2M6Nrhwa+A==",
"dev": true,
"requires": {
"argparse": "1.0.9",
"argparse": "1.0.10",
"entities": "1.1.1",
"linkify-it": "2.0.3",
"mdurl": "1.0.1",
"uc.micro": "1.0.3"
"uc.micro": "1.0.5"
}
},
"marked": {
@@ -3841,7 +3834,7 @@
"integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=",
"dev": true,
"requires": {
"mimic-fn": "1.1.0"
"mimic-fn": "1.2.0"
}
},
"memory-fs": {
@@ -3850,8 +3843,8 @@
"integrity": "sha1-OpoguEYlI+RHz7x+i7gO1me/xVI=",
"dev": true,
"requires": {
"errno": "0.1.4",
"readable-stream": "2.3.3"
"errno": "0.1.7",
"readable-stream": "2.3.4"
}
},
"micromatch": {
@@ -3886,9 +3879,9 @@
}
},
"mimic-fn": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz",
"integrity": "sha1-5md4PZLonb00KBi1IwudYqZyrRg=",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",
"integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==",
"dev": true
},
"minimalistic-assert": {
@@ -3952,7 +3945,7 @@
"console-browserify": "1.1.0",
"constants-browserify": "1.0.0",
"crypto-browserify": "3.12.0",
"domain-browser": "1.1.7",
"domain-browser": "1.2.0",
"events": "1.1.1",
"https-browserify": "1.0.0",
"os-browserify": "0.3.0",
@@ -3960,11 +3953,11 @@
"process": "0.11.10",
"punycode": "1.4.1",
"querystring-es3": "0.2.1",
"readable-stream": "2.3.3",
"readable-stream": "2.3.4",
"stream-browserify": "2.0.1",
"stream-http": "2.7.2",
"stream-http": "2.8.0",
"string_decoder": "1.0.3",
"timers-browserify": "2.0.4",
"timers-browserify": "2.0.6",
"tty-browserify": "0.0.0",
"url": "0.11.0",
"util": "0.10.3",
@@ -4077,10 +4070,13 @@
"dev": true
},
"p-limit": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.1.0.tgz",
"integrity": "sha1-sH/y2aXYi+yAYDWJWiurZqJ5iLw=",
"dev": true
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.2.0.tgz",
"integrity": "sha512-Y/OtIaXtUPr4/YpMv1pCL5L5ed0rumAaAeBSj12F+bSlMdys7i8oQF/GUJmfpTS/QoaRrS/k6pma29haJpsMng==",
"dev": true,
"requires": {
"p-try": "1.0.0"
}
},
"p-locate": {
"version": "2.0.0",
@@ -4088,9 +4084,15 @@
"integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=",
"dev": true,
"requires": {
"p-limit": "1.1.0"
"p-limit": "1.2.0"
}
},
"p-try": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
"integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=",
"dev": true
},
"pako": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz",
@@ -4103,7 +4105,7 @@
"integrity": "sha1-N8T5t+06tlx0gXtfJICTf7+XxxI=",
"dev": true,
"requires": {
"asn1.js": "4.9.2",
"asn1.js": "4.10.1",
"browserify-aes": "1.1.1",
"create-hash": "1.1.3",
"evp_bytestokey": "1.0.3",
@@ -4174,7 +4176,7 @@
"create-hmac": "1.1.6",
"ripemd160": "2.0.1",
"safe-buffer": "5.1.1",
"sha.js": "2.4.9"
"sha.js": "2.4.10"
}
},
"pify": {
@@ -4202,15 +4204,15 @@
"dev": true
},
"process-nextick-args": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
"integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==",
"dev": true
},
"prr": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/prr/-/prr-0.0.0.tgz",
"integrity": "sha1-GoS4WQgyVQFBGFPQCB7j+obikmo=",
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz",
"integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=",
"dev": true
},
"pseudomap": {
@@ -4229,7 +4231,7 @@
"browserify-rsa": "4.0.1",
"create-hash": "1.1.3",
"parse-asn1": "5.1.0",
"randombytes": "2.0.5"
"randombytes": "2.0.6"
}
},
"punycode": {
@@ -4292,21 +4294,21 @@
}
},
"randombytes": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz",
"integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==",
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz",
"integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==",
"dev": true,
"requires": {
"safe-buffer": "5.1.1"
}
},
"randomfill": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.3.tgz",
"integrity": "sha512-YL6GrhrWoic0Eq8rXVbMptH7dAxCs0J+mh5Y0euNekPPYaxEmdVGim6GdoxoRzKW2yJoU8tueifS7mYxvcFDEQ==",
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz",
"integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==",
"dev": true,
"requires": {
"randombytes": "2.0.5",
"randombytes": "2.0.6",
"safe-buffer": "5.1.1"
}
},
@@ -4332,15 +4334,15 @@
}
},
"readable-stream": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz",
"integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==",
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.4.tgz",
"integrity": "sha512-vuYxeWYM+fde14+rajzqgeohAI7YoJcHE7kXDAc4Nk0EbuKnJfqtY9YtRkLo/tqkuF7MsBQRhPnPeyjYITp3ZQ==",
"dev": true,
"requires": {
"core-util-is": "1.0.2",
"inherits": "2.0.3",
"isarray": "1.0.0",
"process-nextick-args": "1.0.7",
"process-nextick-args": "2.0.0",
"safe-buffer": "5.1.1",
"string_decoder": "1.0.3",
"util-deprecate": "1.0.2"
@@ -4354,7 +4356,7 @@
"requires": {
"graceful-fs": "4.1.11",
"minimatch": "3.0.4",
"readable-stream": "2.3.3",
"readable-stream": "2.3.4",
"set-immediate-shim": "1.0.1"
}
},
@@ -4513,9 +4515,9 @@
"dev": true
},
"sha.js": {
"version": "2.4.9",
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.9.tgz",
"integrity": "sha512-G8zektVqbiPHrylgew9Zg1VRB1L/DtXNUVAM6q4QLy8NE3qtHlFXTf8VLL4k1Yl6c7NMjtZUTdXV+X44nFaT6A==",
"version": "2.4.10",
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.10.tgz",
"integrity": "sha512-vnwmrFDlOExK4Nm16J2KMWHLrp14lBrjxMxBJpu++EnsuBmpiYaM/MEs46Vxxm/4FvdP5yTwuCTO9it5FSjrqA==",
"dev": true,
"requires": {
"inherits": "2.0.3",
@@ -4604,18 +4606,18 @@
"dev": true,
"requires": {
"inherits": "2.0.3",
"readable-stream": "2.3.3"
"readable-stream": "2.3.4"
}
},
"stream-http": {
"version": "2.7.2",
"resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.7.2.tgz",
"integrity": "sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw==",
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.0.tgz",
"integrity": "sha512-sZOFxI/5xw058XIRHl4dU3dZ+TTOIGJR78Dvo0oEAejIt4ou27k+3ne1zYmCV+v7UucbxIFQuOgnkTVHh8YPnw==",
"dev": true,
"requires": {
"builtin-status-codes": "3.0.0",
"inherits": "2.0.3",
"readable-stream": "2.3.3",
"readable-stream": "2.3.4",
"to-arraybuffer": "1.0.1",
"xtend": "4.0.1"
}
@@ -4696,9 +4698,9 @@
"dev": true
},
"timers-browserify": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.4.tgz",
"integrity": "sha512-uZYhyU3EX8O7HQP+J9fTVYwsq90Vr68xPEFo7yrVImIxYvHgukBEgOB/SgGoorWVTzGM/3Z+wUNnboA4M8jWrg==",
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.6.tgz",
"integrity": "sha512-HQ3nbYRAowdVd0ckGFvmJPPCOH/CHleFN/Y0YQCX1DVaB7t+KFvisuyN09fuP8Jtp1CpfSh8O8bMkHbdbPe6Pw==",
"dev": true,
"requires": {
"setimmediate": "1.0.5"
@@ -4729,9 +4731,9 @@
"dev": true
},
"uc.micro": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.3.tgz",
"integrity": "sha1-ftUNXg+an7ClczeSWfKndFjVAZI=",
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.5.tgz",
"integrity": "sha512-JoLI4g5zv5qNyT09f4YAvEZIIV1oOjqnewYg5D38dkQljIzpPT296dbIGvKro3digYI1bkb7W6EP1y4uDlmzLg==",
"dev": true
},
"uglify-js": {
@@ -4861,15 +4863,15 @@
}
},
"webpack": {
"version": "3.10.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-3.10.0.tgz",
"integrity": "sha512-fxxKXoicjdXNUMY7LIdY89tkJJJ0m1Oo8PQutZ5rLgWbV5QVKI15Cn7+/IHnRTd3vfKfiwBx6SBqlorAuNA8LA==",
"version": "3.11.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-3.11.0.tgz",
"integrity": "sha512-3kOFejWqj5ISpJk4Qj/V7w98h9Vl52wak3CLiw/cDOfbVTq7FeoZ0SdoHHY9PYlHr50ZS42OfvzE2vB4nncKQg==",
"dev": true,
"requires": {
"acorn": "5.2.1",
"acorn": "5.4.1",
"acorn-dynamic-import": "2.0.2",
"ajv": "5.5.1",
"ajv-keywords": "2.1.1",
"ajv": "6.1.1",
"ajv-keywords": "3.1.0",
"async": "2.6.0",
"enhanced-resolve": "3.4.1",
"escope": "3.6.0",

View File

@@ -8,7 +8,7 @@
"compiler"
],
"author": "Jeremy Ashkenas",
"version": "2.2.0",
"version": "2.2.2",
"license": "MIT",
"engines": {
"node": ">=6"
@@ -43,13 +43,13 @@
"babel-preset-babili": "~0.1.4",
"babel-preset-env": "~1.6.1",
"babel-preset-minify": "^0.3.0",
"codemirror": "^5.32.0",
"codemirror": "^5.35.0",
"docco": "~0.8.0",
"highlight.js": "~9.12.0",
"jison": ">=0.4.18",
"markdown-it": "~8.4.0",
"markdown-it": "~8.4.1",
"underscore": "~1.8.3",
"webpack": "~3.10.0"
"webpack": "~3.11.0"
},
"dependencies": {}
}

View File

@@ -454,10 +454,10 @@ exports.Lexer = class Lexer
indent = match[0]
prev = @prev()
backslash = prev? and prev[0] is '\\'
backslash = prev?[0] is '\\'
@seenFor = no unless backslash and @seenFor
@seenImport = no unless @importSpecifierList
@seenExport = no unless @exportSpecifierList
@seenImport = no unless (backslash and @seenImport) or @importSpecifierList
@seenExport = no unless (backslash and @seenExport) or @exportSpecifierList
size = indent.length - 1 - indent.lastIndexOf '\n'
noNewlines = @unfinished()
@@ -478,7 +478,7 @@ exports.Lexer = class Lexer
if size > @indent
if noNewlines
@indebt = size - @indent
@indebt = size - @indent unless backslash
@suppressNewlines()
return indent.length
unless @tokens.length

View File

@@ -1353,7 +1353,11 @@ exports.Range = class Range extends Base
idx = del o, 'index'
idxName = del o, 'name'
namedIndex = idxName and idxName isnt idx
varPart = "#{idx} = #{@fromC}"
varPart =
if known and not namedIndex
"var #{idx} = #{@fromC}"
else
"#{idx} = #{@fromC}"
varPart += ", #{@toC}" if @toC isnt @toVar
varPart += ", #{@step}" if @step isnt @stepVar
[lt, gt] = ["#{idx} <#{@equals}", "#{idx} >#{@equals}"]
@@ -1361,23 +1365,18 @@ exports.Range = class Range extends Base
# Generate the condition.
[from, to] = [@fromNum, @toNum]
# Always check if the `step` isn't zero to avoid the infinite loop.
stepCond = if @stepNum then "#{@stepNum} !== 0" else "#{@stepVar} !== 0"
stepNotZero = "#{ @stepNum ? @stepVar } !== 0"
stepCond = "#{ @stepNum ? @stepVar } > 0"
lowerBound = "#{lt} #{ if known then to else @toVar }"
upperBound = "#{gt} #{ if known then to else @toVar }"
condPart =
if known
unless @step?
if from <= to then "#{lt} #{to}" else "#{gt} #{to}"
else
# from < to
lowerBound = "#{from} <= #{idx} && #{lt} #{to}"
# from > to
upperBound = "#{from} >= #{idx} && #{gt} #{to}"
if from <= to then "#{stepCond} && #{lowerBound}" else "#{stepCond} && #{upperBound}"
else
# from < to
lowerBound = "#{@fromVar} <= #{idx} && #{lt} #{@toVar}"
# from > to
upperBound = "#{@fromVar} >= #{idx} && #{gt} #{@toVar}"
"#{stepCond} && (#{@fromVar} <= #{@toVar} ? #{lowerBound} : #{upperBound})"
if @step?
"#{stepNotZero} && (#{stepCond} ? #{lowerBound} : #{upperBound})"
else
if known
"#{ if from <= to then lt else gt } #{to}"
else
"(#{@fromVar} <= #{@toVar} ? #{lowerBound} : #{upperBound})"
cond = if @stepVar then "#{@stepVar} > 0" else "#{@fromVar} <= #{@toVar}"
@@ -2408,8 +2407,8 @@ exports.Assign = class Assign extends Base
# Sort 'splatsAndExpans' so we can show error at first disallowed token.
objects[splatsAndExpans.sort()[1]].error "multiple splats/expansions are disallowed in an assignment"
isSplat = splats.length
isExpans = expans.length
isSplat = splats?.length > 0
isExpans = expans?.length > 0
isObject = @variable.isObject()
isArray = @variable.isArray()
@@ -2458,7 +2457,7 @@ exports.Assign = class Assign extends Base
# "Complex" `objects` are processed in a loop.
# Examples: [a, b, {c, r...}, d], [a, ..., {b, r...}, c, d]
loopObjects = (objs, vvarTxt) =>
loopObjects = (objs, vvar, vvarTxt) =>
objSpreads = hasObjSpreads objs
for obj, i in objs
# `Elision` can be skipped.
@@ -2488,16 +2487,16 @@ exports.Assign = class Assign extends Base
assigns.push new Assign(vvar, vval, null, param: @param, subpattern: yes).compileToFragments o, LEVEL_LIST
# "Simple" `objects` can be split and compiled to arrays, [a, b, c] = arr, [a, b, c...] = arr
assignObjects = (objs, vvarTxt) =>
assignObjects = (objs, vvar, vvarTxt) =>
vvar = new Value new Arr(objs, yes)
vval = if vvarTxt instanceof Value then vvarTxt else new Value new Literal(vvarTxt)
assigns.push new Assign(vvar, vval, null, param: @param, subpattern: yes).compileToFragments o, LEVEL_LIST
processObjects = (objs, vvarTxt) ->
processObjects = (objs, vvar, vvarTxt) ->
if complexObjects objs
loopObjects objs, vvarTxt
loopObjects objs, vvar, vvarTxt
else
assignObjects objs, vvarTxt
assignObjects objs, vvar, vvarTxt
# In case there is `Splat` or `Expansion` in `objects`,
# we can split array in two simple subarrays.
@@ -2514,7 +2513,7 @@ exports.Assign = class Assign extends Base
expIdx = splatsAndExpans[0]
leftObjs = objects.slice 0, expIdx + (if isSplat then 1 else 0)
rightObjs = objects.slice expIdx + 1
processObjects leftObjs, vvarText if leftObjs.length isnt 0
processObjects leftObjs, vvar, vvarText if leftObjs.length isnt 0
if rightObjs.length isnt 0
# Slice or splice `objects`.
refExp = switch
@@ -2524,10 +2523,10 @@ exports.Assign = class Assign extends Base
restVar = refExp
refExp = o.scope.freeVariable 'ref'
assigns.push [@makeCode(refExp + ' = '), restVar.compileToFragments(o, LEVEL_LIST)...]
processObjects rightObjs, refExp
processObjects rightObjs, vvar, refExp
else
# There is no `Splat` or `Expansion` in `objects`.
processObjects objects, vvarText
processObjects objects, vvar, vvarText
assigns.push vvar unless top or @subpattern
fragments = @joinFragmentArrays assigns, ', '
if o.level < LEVEL_LIST then fragments else @wrapInParentheses fragments

View File

@@ -945,3 +945,43 @@ test "#4673: complex destructured object spread variables", ->
{{g}...} = g: 1
eq g, 1
test "#4878: Compile error when using destructuring with a splat or expansion in an array", ->
arr = ['a', 'b', 'c', 'd']
f1 = (list) ->
[first, ..., last] = list
f2 = (list) ->
[first..., last] = list
f3 = (list) ->
([first, ...] = list); first
f4 = (list) ->
([first, ...rest] = list); rest
arrayEq f1(arr), arr
arrayEq f2(arr), arr
arrayEq f3(arr), 'a'
arrayEq f4(arr), ['b', 'c', 'd']
foo = (list) ->
ret =
if list?.length > 0
[first, ..., last] = list
[first, last]
else
[]
arrayEq foo(arr), ['a', 'd']
bar = (list) ->
ret =
if list?.length > 0
[first, ...rest] = list
[first, rest]
else
[]
arrayEq bar(arr), ['a', ['b', 'c', 'd']]

View File

@@ -1287,3 +1287,56 @@ test "#4871: `else if` no longer output together ", ->
2;
}
'''
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

View File

@@ -853,3 +853,70 @@ test "#4491: import- and export-specific lexing should stop after import/export
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';
"""

View File

@@ -130,43 +130,43 @@ test "#2047: Infinite loop possible when `for` loop with `range` uses variables"
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]]
]
@@ -182,10 +182,10 @@ test "#2047: from, to and step as variables", ->
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]
@@ -195,3 +195,50 @@ test "#2047: from, to and step as variables", ->
step = 0
r = (x for x in [b..a] by step)
arrayEq r, []
test "#4884: Range not declaring var for the 'i'", ->
'use strict'
[0..21].forEach (idx) ->
idx + 1
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]