File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -137,10 +137,11 @@ exports.doID = function(code, index){
137137 return this . token ( 'LITERAL' , id , true ) . length ;
138138 case 'for' :
139139 this . seenFor = true ;
140- // fallthrough
141- case 'then' :
142140 this . wantBy = false ;
143141 break ;
142+ case 'then' :
143+ this . seenFor = this . wantBy = false ;
144+ break ;
144145 case 'catch' :
145146 case 'function' :
146147 id = '' ;
@@ -461,7 +462,7 @@ exports.doLine = function(code, index){
461462 this . newline ( ) ;
462463 }
463464 }
464- this . wantBy = false ;
465+ this . seenFor = this . wantBy = false ;
465466 return length ;
466467} ;
467468exports . doSpace = function ( code , lastIndex ) {
@@ -684,6 +685,7 @@ exports.doLiteral = function(code, index){
684685 break ;
685686 case '=>' :
686687 this . unline ( ) ;
688+ this . seenFor = false ;
687689 if ( that = this . doInlinedent ( code , index + 2 ) ) {
688690 return 1 + that ;
689691 }
Original file line number Diff line number Diff line change @@ -105,8 +105,8 @@ exports import
105105 case \return \throw then tag = \HURL
106106 case \break \continue then tag = \JUMP
107107 case \this \eval \super then return @token(\LITERAL id, true)length
108- case \for then @seenFor = true; fallthrough
109- case \then then @wantBy = false
108+ case \for then @seenFor = true; @wantBy = false
109+ case \then then @seenFor = @wantBy = false
110110 case \catch \function then id = ''
111111 case \in \of
112112 if @seenFor
@@ -330,7 +330,7 @@ exports import
330330 IN OF TO BY FROM EXTENDS IMPLEMENTS ]>
331331 return length
332332 if delta then @indent delta else @newline!
333- @wantBy = false
333+ @seenFor = @ wantBy = false
334334 length
335335
336336 # Consumes non-newline whitespaces and/or a line comment.
@@ -440,6 +440,7 @@ exports import
440440 case \.. then @adi!; tag = \ID; val = up || \constructor
441441 case \=>
442442 @unline!
443+ @seenFor = false
443444 return 1 + that if @doInlinedent code, index+2
444445 tag = \THEN
445446 default if \< is val.charAt 0
Original file line number Diff line number Diff line change @@ -210,6 +210,14 @@ continue for, o.count!_ in [1 2]
210210eq o.i, 4
211211
212212
213+ # [#195](https://github.com/satyr/coco/issues/195)
214+ for [0]
215+ ok 0 in {0}
216+ for [1] then ok 1 of [1]
217+ for [2] => ok 2 of [2]
218+ ok 3 not in []
219+
220+
213221### Line folding before/after `for` prepositions
214222for x
215223in {2}
You can’t perform that action at this time.
0 commit comments