killme2008 / aviatorscript

A high performance scripting language hosted on the JVM.
http://fnil.net/aviator/
4.45k stars 831 forks source link

递归调用报错 #568

Closed magnww closed 11 months ago

magnww commented 1 year ago

版本:5.3.3 测试代码

    @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)

目前是不支持递归吗?

killme2008 commented 11 months ago

v5.4.1 修复 https://github.com/killme2008/aviatorscript/releases/tag/aviator-5.4.1