Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getVariableNames会返回true/false/nil等非变量名 #186

Closed
6768745e opened this issue Dec 27, 2019 · 6 comments
Closed

getVariableNames会返回true/false/nil等非变量名 #186

6768745e opened this issue Dec 27, 2019 · 6 comments
Labels

Comments

@6768745e
Copy link

根据文档描述, getVariableNames和getVariableFullNames返回的是表达式中变量的名字,但是以下表达式的上述两个方法会返回true:

1 == 1
@killme2008
Copy link
Owner

应该没有针对这个情况做处理,这个情况会直接优化成结果 true,算是一个 bug

@killme2008 killme2008 added the bug label Dec 27, 2019
@killme2008
Copy link
Owner

aviator 内部将 true/false 其实也是当成了变量来处理,所以理论上说这个返回也没有错,只是比较出人意料。

@6768745e
Copy link
Author

aviator 内部将 true/false 其实也是当成了变量来处理

这是内部实现的逻辑。但是对使用人来说,将true/false当做变量有点意外。此外,nil在wiki上明确说是常量,所以getVariableNames和getVariableFullNames返回ni应该是个bug, 比如以下的表达式:

a != nil

@killme2008
Copy link
Owner

nil 内部其实也只是一个特别的 variable。 这个问题会去修正下,你可以先过滤掉这些 keyword 。

@6768745e
Copy link
Author

嗯,我手动把true/false/nil这些过滤掉的。

@killme2008
Copy link
Owner

发布了 4.2.9(可能要等一天等 maven central 同步)
https://github.com/killme2008/aviator/releases/tag/aviator-4.2.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants