killme2008 / aviatorscript

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

嵌套lambda参数的bug #134

Closed hug3id closed 5 years ago

hug3id commented 5 years ago

版本:4.1.2

Map<String, Object> env = new HashMap<>(2); env.put("v", 3); AviatorEvaluator.execute("func=lambda(v)->v+2 end;func2=lambda(v)->func(v) end;print(func(1));print(func2(1))", env); 结果输出:35

执行代码如下: func=lambda(v)->v+2 end; func2=lambda(v)->func(v) end; print(func(1)); // 输出 3,正确 print(func2(1)) // 输出 5,错误,应该是3

跟踪输出如下: [Aviator TRACE] Func : func(<Long, 1>) [Aviator TRACE] <JavaType, 1, Long> + <Long, 2> => <Long, 3> [Aviator TRACE] Result : 3 [Aviator TRACE] Func : print(<JavaType, 3, Long>) [Aviator TRACE] Func : func2(<Long, 1>) [Aviator TRACE] Func : func(<JavaType, 1, Long>) [Aviator TRACE] <JavaType, 3, Integer> + <Long, 2> => <Long, 5> [Aviator TRACE] Result : 5 [Aviator TRACE] Result : 5 [Aviator TRACE] Func : print(<JavaType, 5, Long>) [Aviator TRACE] Result : null

killme2008 commented 5 years ago

恩,这是个 bug,还是命名捕获上的问题,跟嵌套没有关系,我尽快修复下。

killme2008 commented 5 years ago

已经在 https://github.com/killme2008/aviator/pull/127 修复,着急可以先自己打包一个。我争取周末发下。

hug3id commented 5 years ago

@killme2008 十分感谢!

killme2008 commented 5 years ago

4.2.0 发布 https://github.com/killme2008/aviator/releases/tag/aviator-4.2.0