lazy functions with set parameter sizes will report an error if no properly specced. Fixes #1064

This commit is contained in:
gnembon committed 2021-09-06 23:05:13 -03:00
1 parent 229d0b037b
commit 36df542072
6 files changed
+45 -12

No files matched your search

@@ -489,6 +489,39 @@ public class Expression
return false;
}
@Override
public LazyValue lazyEval(Context c, Context.Type i, Expression e, Tokenizer.Token t, List<LazyValue> lazyParams)
{
ILazyFunction.checkInterrupts();
if (num_params >= 0 && lazyParams.size() != num_params)
throw new InternalExpressionException("'"+name+"' requires "+num_params+" parameters, "+lazyParams.size()+" provided.");
try
{
return fun.apply(c, i, lazyParams);
}
catch (RuntimeException exc)
{
throw handleCodeException(c, exc, e, t);
}
}
});
}
public void addLazyFunction(String name, TriFunction<Context, Context.Type, List<LazyValue>, LazyValue> fun)
{
functions.put(name, new AbstractLazyFunction(-1, name)
{
@Override
public boolean pure() {
return false;
}
@Override
public boolean transitive() {
return false;
}
@Override
public LazyValue lazyEval(Context c, Context.Type i, Expression e, Tokenizer.Token t, List<LazyValue> lazyParams)
{