-
Notifications
You must be signed in to change notification settings - Fork 13
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
pe_assert #86
Comments
Is the behaviour exactly identical to |
Well, the intended behavior would be that |
What is the behaviour if the condition is not provably false nor provably true during PE? |
@madmann91 Good question…I guess that should just be a hard error as asserting that a condition be true during PE would obviously require that the condition is actually one that can be checked during PE? Thinking about it, that would probably also make this a good debugging tool as it would allow one to make sure that certain things are actually getting PE'ed the way one expected them to be; and catch if they don't… So then to rephrase:
should be ignored if |
We could simply emit a runtime assert() evaluating the expression instead with the same diagnostic for the corresponding source location (e.g. when compiling in debug mode). |
The problem with that is that it will be very common to have the condition be neither provably true nor provably false during partial evaluation. With the current partial evaluator, it could be that the call to fn do_stuff(c: bool) -> () {
let mut x = 33;
let mut y = 5;
if c {
y = 3;
}
// The condition cannot be evaluated at partial evaluation time
// because the partial evaluator is not able to see the value of
// x after the branch (that's a limitation of the current impl.)
pe_assert(x == 33);
} |
Optimizing this is btw not super trivial. You'll need to integrate
with the partial evaluator to make things like this work reliably. I'm currently working on this in the |
It would be really great to have some sort of
static_assert
during partial evaluation, e.g.,to make compilation fail with a meaningful error message in cases where domain-specific sanity checks can tell us at compile time that the generated code will be meaningless…
The text was updated successfully, but these errors were encountered: