-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
The code to reproduce the bug:
module Reproducer {
void run() {
Char[] chars = new Array<Char>(2);
Int offset = 0;
if (chars[offset++] := next()) {
assert offset == 1;
} else {
// the offset must not have been incremented, but it has been
assert offset == 0;
}
}
conditional Char next() = False;
}
Currently, the offset++ increment happens before the conditional method next() is called, which is wrong. It should only happen after next{} returns with a positive (True) result.
Similarly, the following code works incorrectly; the index() method must not be called upon a negative response from next() method.
module Reproducer2 {
void run() {
Char[] chars = new Array<Char>(2);
chars[index()] := next();
}
conditional Char next() = False;
Int index() {
assert False as "This should not be called";
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels