-
Notifications
You must be signed in to change notification settings - Fork 164
FunC codegen error for obvious cases of zero division in statements #716
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
Comments
Mmmm... the main problem I see here is that const-eval (or the interpreter) is only called to simplify expressions. For example, inside function To solve this issue, we would need some form of code analysis outside of const-eval. Another possibility would be to attempt calling functions that do not have parameters, just to check if its execution generates an error. |
To solve this issue you need to partially evaluate contracts (I almost always mean partial evaluation or constant evaluation by "const-eval", sorry if that's confusing) |
this fails too (explicit contract EdgeCases {
fun testShortCircuit(x: Int): Bool {
return x != 0 || (x / 0 == 1);
}
receive () {
self.testShortCircuit(1);
}
} LLM Fuzzing discovery (see #2490) |
In this one, FunC reports an error, but the program would not produce a division by zero at runtime, because Hence, I think that analyzing It will depend of what we want for the analyzer. Either: to report an error if there is a potential division by zero (as FunC does in this case), or to report an error only if there is a certain division by zero. |
Results in the following error message from FunC:
As far as I understand this happens during code generation when going from FunC to Fift-asm.
To resolve this, we need to track variables whose values can be determined at compile-time.
The text was updated successfully, but these errors were encountered: