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
Either the behavior indicated by the test (eg: a new struct to be created with the values swapped (eg {.x = 4, .y = 10} after v.flip() and for that value to be assigned to v replacing it.)
test "it should swap the values" {
var v = Pair{.x = 10, .y = 4};
v = v.flip();
try std.testing.expectEqual(v.y, 10);
try std.testing.expectEqual(v.x, 4); //Fails, it's 10 now
}
OR
A warning or compile error suggesting that assigning to a return value that is a modification of this can be optimized in undefined ways.
Actual Behavior
The value of x is set to 10 because it assigned first, then y is set to the new value of x (10) instead of the value that is being passed in via the struct (4).
test "what actually happens" {
var v = Pair{.x = 10, .y = 4};
v = v.flip();
try std.testing.expectEqual(v.x, 10);
try std.testing.expectEqual(v.y, 10);
}
The text was updated successfully, but these errors were encountered:
miquille
added
the
bug
Observed behavior contradicts documented or intended behavior
label
May 6, 2022
Zig Version
0.9.1
Steps to Reproduce
OS: Mac OS 12.3.1 (21E258), arm64
Note: Adding a temporary value resolves the problem, eg:
Expected Behavior
Either the behavior indicated by the test (eg: a new struct to be created with the values swapped (eg {.x = 4, .y = 10} after
v.flip()
and for that value to be assigned tov
replacing it.)OR
A warning or compile error suggesting that assigning to a return value that is a modification of this can be optimized in undefined ways.
Actual Behavior
The value of x is set to 10 because it assigned first, then y is set to the new value of x (10) instead of the value that is being passed in via the struct (4).
The text was updated successfully, but these errors were encountered: