Skip to content
Permalink
Browse files

FIX: can use "if foo then break" within the comprehensions you are al…

…lowed to use break in.
  • Loading branch information...
shanebdavis committed Jul 6, 2019
1 parent d434d48 commit 0bd03afd39a2e1766a9dd0abc5bd3ea047d77869
@@ -36,6 +36,25 @@ Syntax Highlighting


# To Sort
```coffeescript
# compile error
switch
when if a then b else c
213
else 555
# actual use case:
switch
when error.info extract? response
"hi"
```

```coffeescript
# compile error for this:
object a from-array b
c
```

```coffeescript
# new & change: /// regex blocks should accept any kind of string:
@@ -3,7 +3,7 @@ import &StandardImport
class BreakStatementStn extends &BaseStn

validate: ->
p = @findParent /^(Class|Comprehension|FunctionDefinition|While|Switch|ControlOperator)$/
p = @findParent /^(Class|Comprehension|FunctionDefinition|While|Switch)$/
switch
when !p? then throw new Error "'break' not allowed in root context."
when /^(Comprehension)/.test(p.type) && p.getGeneratesInlineIteration() then null
@@ -12,7 +12,7 @@ Caf.defMod(module, () => {
this.prototype.validate = function() {
let p;
p = this.findParent(
/^(Class|Comprehension|FunctionDefinition|While|Switch|ControlOperator)$/
/^(Class|Comprehension|FunctionDefinition|While|Switch)$/
);
return (() => {
switch (false) {
@@ -20,7 +20,24 @@ module.exports = suite: parseTestSuite
return:
"array a in-array b with return a": null


break:
"""
each a in-array 1 2
if a == 2
break a + 100
""": "
let from, into, to, i;
from = [1, 2];
into = from;
if (from != null)
{to = from.length;
i = 0;
while (i < to)
{let a;
a = from[i];
if (a === 2) {into = a + 100; break;};
i++;};};
into;"

array:
destructuring:
@@ -104,6 +104,11 @@ module.exports = suite: semanticTestSuite
break:
"each a in-array 1 2 with break 123": 123
"out = each a in-array 1 2 with break 123": 123
"""
each a in-array 1 2
if a == 2
break a + 100
""": 102

find:
basic:

0 comments on commit 0bd03af

Please sign in to comment.
You can’t perform that action at this time.