You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.
let x: bool = true;
stdout.println(x);
x = !x;
stdout.println(x);
You would expect it to output:
1
0
However, in reality it outputs:
1
1
This is a bug in the assignment implementation. The current implementation unconditionally zeros the target (lhs) of the assignment. This fails when doing self-assignment.
To fix this is non-trivial because the assignment does not know about its target at all. It treats the rhs expression as a black box and there is no way to inspect the result.
The more fundamental issue with this code is that it assumes that it is decidable whether the target should be zeroed beforeexpression::into_operations is called. The assumption that expression::into_operation makes about the target being zero is just not sound. We should probably add a parameter into that function to indicate whether the target was just initialized or may need to be zeroed. Then expression::into_operations can decide what the proper course of action is.
Another related problem: This works for some reason:
let a: bool = a;
Notice that a can be used before it is properly initialized.
The text was updated successfully, but these errors were encountered:
Consider the following code:
You would expect it to output:
However, in reality it outputs:
This is a bug in the assignment implementation. The current implementation unconditionally zeros the target (lhs) of the assignment. This fails when doing self-assignment.
To fix this is non-trivial because the assignment does not know about its target at all. It treats the rhs expression as a black box and there is no way to inspect the result.
The more fundamental issue with this code is that it assumes that it is decidable whether the target should be zeroed before
expression::into_operations
is called. The assumption thatexpression::into_operation
makes about the target being zero is just not sound. We should probably add a parameter into that function to indicate whether the target was just initialized or may need to be zeroed. Thenexpression::into_operations
can decide what the proper course of action is.Another related problem: This works for some reason:
Notice that a can be used before it is properly initialized.
The text was updated successfully, but these errors were encountered: