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

在if-else、嵌套if中使用continue无法生效 #394

Closed
saber-Railgun opened this issue Jun 16, 2021 · 5 comments
Closed

在if-else、嵌套if中使用continue无法生效 #394

saber-Railgun opened this issue Jun 16, 2021 · 5 comments

Comments

@saber-Railgun
Copy link

saber-Railgun commented Jun 16, 2021

使用版本为5.2.1。

for i in range(0, 10) {
if (i == 3) {
continue;
} else {
let j = 10 + i;
}
p(i);
}
如上述代码,参照java中continue的语义,应该不会打印3。但实际运行结果是打印了3,截图如下
image

for i in range(0, 10) {
if (i == 3) {
continue;
}
p(i);
}
如果去掉else,则运行结果就不会打印3了,截图如下
image

根据语雀中对于continue关键字的定义,并没有提到上述相关特性。https://www.yuque.com/boyan-avfmj/aviatorscript/vfqgqn
请问这是个bug还是文档描述不清晰呢?

在嵌套if中同样无法生效。代码示例如下
for i in range(0, 10) {
if (i>3) {
if (i==4){
continue;
}
}
p(i);
}
输出为
image

@saber-Railgun saber-Railgun changed the title 在if-else中使用continue无法生效 在if-else、嵌套if中使用continue无法生效 Jun 17, 2021
@killme2008
Copy link
Owner

似乎是 continue 的 bug,我看下

@killme2008
Copy link
Owner

killme2008 commented Jun 22, 2021

确认是严重的 bug,惭愧,竟然测试用例没有覆盖到 continue 这个 case,我尽快修复发个版本。

在 continue 和 if/else 共同出现,或者continue 和嵌套 if 的场景,会出现此不符合预期的行为。问题出在 IfCallccFunction 函数的实现上。

@saber-Railgun
Copy link
Author

好的,辛苦了。

@killme2008
Copy link
Owner

@saber-Railgun 已修复,可以用 v5.2.6 这个分支来测试,回忆下应该是当时做重构,忘了去掉这个判断条件了,太尴尬了。
#376

今天会发布掉 5.2.6

@killme2008
Copy link
Owner

已发布 5.2.6,推荐升级

https://github.com/killme2008/aviatorscript/releases/tag/aviator-5.2.6

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

No branches or pull requests

2 participants