fixed a bug where `while` condition was compiling as statement

This commit is contained in:
satyr 2010-10-11 20:29:08 +09:00
parent e89d7a7756
commit 9c55bd59a1
3 changed files with 6 additions and 2 deletions

View File

@ -1294,9 +1294,9 @@
var cond, post, pre, rvar, set, top;
top = del(o, 'top') && !this.returns;
o.indent = this.idt(1);
o.top = true;
this.condition.parenthetical = true;
cond = this.condition.compile(o);
o.top = true;
set = '';
if (!top) {
rvar = o.scope.freeVariable('result');

View File

@ -1126,9 +1126,9 @@ exports.While = class While extends Base
compileNode: (o) ->
top = del(o, 'top') and not @returns
o.indent = @idt 1
o.top = true
@condition.parenthetical = yes
cond = @condition.compile(o)
o.top = true
set = ''
unless top
rvar = o.scope.freeVariable 'result'

View File

@ -47,3 +47,7 @@ loop
list.push i * 2
ok list.join(' ') is '8 6 4 2'
#759: `if` within `while` condition
2 while if 1 then 0