Diff
Not logged in

Differences From Artifact [74dd93745d781116]:

To Artifact [56f0a662740b0906]:


135 135 136 136 Value eval( Let e, Layer lay, Table ctx, bool overwriteCtx=CascadeCtx ) 137 137 { 138 138 Table newCtx = overwriteCtx ? ctx : new Table(ctx, Table.Kind.NotPropagateSet); 139 139 if( isASTLayer(lay) ) 140 140 return ast2table(e, (AST ee){ 141 141 // need this for correct scoping (outer scope macro variables must be hidden!) 142 - if(ee is e.expr) 142 + if(e.name!="_" && ee is e.expr) 143 143 newCtx.set(e.name, NoopLayer, null); 144 144 return eval(ee,lay,newCtx); 145 145 }); 146 146 else 147 147 { 148 148 Value ri = eval(e.init, lay, newCtx); 149 - newCtx.set(e.name, e.layer.empty ? lay : e.layer, ri); 149 + if(e.name!="_") 150 + newCtx.set(e.name, e.layer.empty ? lay : e.layer, ri); 150 151 return eval(e.expr, lay, newCtx, OverwriteCtx); 151 152 } 152 153 } 153 154 154 155 private: 155 156 // little little bit incremental macro defining version. 156 157 // enables @macro foo(x)=... in ... foo ..., only at the top level of the ................................................................................ 459 460 } 460 461 unittest 461 462 { 462 463 auto e = new Evaluator; 463 464 enrollRuntimeLibrary(e); 464 465 assert_nothrow( e.evalString(`case 1`) ); 465 466 assert_nothrow( e.evalString(`case 1 when 1: 2`) ); 467 + 468 + // this is a shorthand for 469 + // @macro x = fun(){} in @macro(x) 470 + // so it is ok to fail, but it is really incovenient on REPL 471 + assert_nothrow( e.evalString(`@macro x=fun(){}`) ); 466 472 } 467 473 468 474 /* 469 475 unittest 470 476 { 471 477 assert_eq( evalString(`var fac = fun(x){ 472 478 if(x)