Diff
Not logged in

Differences From Artifact [84ee94a6f293fac0]:

To Artifact [360da420d41dfbbf]:


126 } 126 } 127 }, 127 }, 128 (LayeredExpression e) 128 (LayeredExpression e) 129 { 129 { 130 if( e.lay == "@macro" ) 130 if( e.lay == "@macro" ) 131 return macroEval(e.expr, ctx, false); 131 return macroEval(e.expr, ctx, false); 132 else 132 else 133 return eval(e.expr, ctx, false, e.lay); | 133 return eval(e.expr, ctx, true, e.lay); 134 }, 134 }, 135 (LetExpression e) 135 (LetExpression e) 136 { 136 { 137 // for letrec, we need this, but should avoid overwritin 137 // for letrec, we need this, but should avoid overwritin 138 // ctx.set(e.var, "@v", new UndefinedValue, e.pos); 138 // ctx.set(e.var, "@v", new UndefinedValue, e.pos); 139 Value v = eval(e.init, ctx, true, lay); < 140 if(splitCtx) 139 if(splitCtx) 141 ctx = new Table(ctx, Table.Kind.NotPropagateSet) 140 ctx = new Table(ctx, Table.Kind.NotPropagateSet) > 141 Value v = eval(e.init, ctx, true, lay); 142 ctx.set(e.var, (e.layer.length ? e.layer : lay), v, e.po 142 ctx.set(e.var, (e.layer.length ? e.layer : lay), v, e.po 143 return eval(e.expr, ctx, false, lay); 143 return eval(e.expr, ctx, false, lay); 144 }, 144 }, 145 (FuncallExpression e) 145 (FuncallExpression e) 146 { 146 { 147 Value _f = eval(e.fun, ctx, true, lay); 147 Value _f = eval(e.fun, ctx, true, lay); 148 if( auto f = cast(FunValue)_f ) { 148 if( auto f = cast(FunValue)_f ) { ................................................................................................................................................................................ 379 assert_eq( evalString(`@@s(x){x}; @s "+"=fun(x,y){@v(@s(x)-@s(y))};1+2`) 379 assert_eq( evalString(`@@s(x){x}; @s "+"=fun(x,y){@v(@s(x)-@s(y))};1+2`) 380 assert_eq( evalString(`@@s(x){x}; @s "+"=fun(x,y){@v(@s(x)-@s(y))};@s(1+ 380 assert_eq( evalString(`@@s(x){x}; @s "+"=fun(x,y){@v(@s(x)-@s(y))};@s(1+ 381 } 381 } 382 382 383 unittest 383 unittest 384 { 384 { 385 assert_eq( evalString(`@@t = fun(x){x+1}; @t(123)`).val, new IntValue(Bi 385 assert_eq( evalString(`@@t = fun(x){x+1}; @t(123)`).val, new IntValue(Bi > 386 // there was a bug that declaration in the first line of function defini > 387 // cannot be recursive > 388 assert_nothrow( evalString(`def foo() { > 389 def bar(y) { if(y<1) {0} else {bar(0)} }; > 390 bar(1) > 391 }; foo()`) ); 386 } 392 }