围攻
Logic extensions mod
Zane49er 2021 年 8 月 5 日 下午 9:22
Bug? or bad code?
I am trying to run some code, and it fails inside a try/catch but still crashes the CPU block.
Is there something try/catch doesn't work on, or is this a mod error?
I know java but have never worked with javascript so sorry if this is a dumb question.


function start() {
try{
if(readSensor(3)){
print("a");
let {velocity:a} = readSensor(3);
print("b");
}
}
catch(err){
print("c");
print(err);
}
finally{
setTimeout(0.1, start);
}
}

start();
< >
正在显示第 1 - 2 条,共 2 条留言
Lambda  [开发者] 2021 年 8 月 13 日 上午 10:32 
Hello,

This seems to be a bug in Jint interpreter (or maybe this code does not follow some old version of EcmaScript specification that Jint is using, IDK).
You can fix it by declaring "a" variable before let {velocity:a} = readSensor(3) expression.

BTW JavaScript has no any relation to java, the word "java" here is just marketing stuff.
Lambda  [开发者] 2021 年 8 月 13 日 上午 10:56 
I've patched Jint a bit to make this exception catchable. But I'm not sure how to get this code to work, I don't really know internals of Jint interpreter.
< >
正在显示第 1 - 2 条,共 2 条留言
每页显示数: 1530 50