@Test
public void testRecursion() {
String script = """
fn post_order(nodes) {
for node in nodes {
if (node.children != nil && !is_empty(node.children)) {
post_order(node.children);
}
p(node.value);
}
}
let tree = seq.list(seq.map(
"value", 1,
"children", seq.list(seq.map(
"value", 2,
"children", seq.list(seq.map(
"value", 3))), seq.map(
"value", 4))));
post_order(tree);
""";
AviatorEvaluator.execute(script);
}
错误信息
3
2
4
java.lang.AssertionError
at com.googlecode.aviator.runtime.function.LambdaFunction.newEnv(LambdaFunction.java:248)
at com.googlecode.aviator.runtime.function.LambdaFunction.call(LambdaFunction.java:115)
at com.googlecode.aviator.runtime.function.internal.ReducerFunction.reduce(ReducerFunction.java:137)
at com.googlecode.aviator.runtime.function.internal.ReducerFunction.call(ReducerFunction.java:44)
at Script_1693997427913_59.execute0(Script_1693997427913_59:8)
at com.googlecode.aviator.ClassExpression.executeDirectly(ClassExpression.java:44)
at com.googlecode.aviator.runtime.function.LambdaFunction.call(LambdaFunction.java:129)
at com.googlecode.aviator.runtime.RuntimeFunctionDelegator.call(RuntimeFunctionDelegator.java:63)
at Script_1693997427913_61.execute0(Script_1693997427913_61:4)
at com.googlecode.aviator.ClassExpression.executeDirectly(ClassExpression.java:44)
at com.googlecode.aviator.runtime.function.LambdaFunction.call(LambdaFunction.java:115)
at Script_1693997427913_60.execute0(Script_1693997427913_60:5)
at com.googlecode.aviator.ClassExpression.executeDirectly(ClassExpression.java:44)
at com.googlecode.aviator.runtime.function.LambdaFunction.call(LambdaFunction.java:129)
at com.googlecode.aviator.runtime.function.internal.ReducerFunction.reduce(ReducerFunction.java:65)
at com.googlecode.aviator.runtime.function.internal.ReducerFunction.call(ReducerFunction.java:44)
at Script_1693997427913_59.execute0(Script_1693997427913_59:8)
at com.googlecode.aviator.ClassExpression.executeDirectly(ClassExpression.java:44)
at com.googlecode.aviator.runtime.function.LambdaFunction.call(LambdaFunction.java:129)
at com.googlecode.aviator.runtime.RuntimeFunctionDelegator.call(RuntimeFunctionDelegator.java:63)
at Script_1693997427913_58.execute0(Script_1693997427913_58:17)
at com.googlecode.aviator.ClassExpression.executeDirectly(ClassExpression.java:44)
at com.googlecode.aviator.BaseExpression.execute(BaseExpression.java:246)
at com.googlecode.aviator.AviatorEvaluatorInstance.execute(AviatorEvaluatorInstance.java:1670)
at com.googlecode.aviator.AviatorEvaluatorInstance.execute(AviatorEvaluatorInstance.java:1685)
at com.googlecode.aviator.AviatorEvaluator.execute(AviatorEvaluator.java:544)
at com.googlecode.aviator.AviatorEvaluator.execute(AviatorEvaluator.java:565)
版本:5.3.3 测试代码
错误信息
目前是不支持递归吗?