@@ -418,9 +418,9 @@ (*p)[1] ++; return (*p)[0]; } else - memo[memokey] = tuple(evlay.lift(new BottomValue, ctx, pos), 0); + memo[memokey] = tuple(cast(Value)new BottomValue, 0); Value r = nonMemoizedRun(); int touched = memo[memokey][1]; @@ -466,12 +466,13 @@ throw genex!RuntimeException(pos, text("only ", defLay, " layer can call native function: ", name)); T typed_args; foreach(i, Ti; T) { - typed_args[i] = cast(Ti) ctx.get(text(i), ValueLayer, pos); + Value vi = ctx.get(text(i), ValueLayer, pos); + typed_args[i] = cast(Ti) vi; if( typed_args[i] is null ) throw genex!RuntimeException(pos, - sprintf!"type mismatch on the argument %d of native function: %s"(i+1,name)); + sprintf!"type mismatch on the argument %d of native function %s. %s required but %s passed."(i+1,name,typeid(Ti),vi)); } try { return dg(typed_args); } catch( RuntimeException e ) { @@ -484,8 +485,19 @@ } version(unittest) import polemy.runtime; + +unittest +{ + auto e = new Evaluator; + enrollRuntimeLibrary(e); + assert_eq( e.evalString(` +@@foo(x){x*2}; +@foo "+" (x,y){x}; +@foo(3+4) +`), new IntValue(6) ); +} unittest { auto e = new Evaluator;