solang
solang copied to clipboard
[Inconsistent with solc]: The assignment order is different.
Solang version: v0.3.3-70-g32a45ea1 Description: In solc + EVM, the value of y is 1, but in solang + SVM, the value of y is 3.
contract C {
uint256 x;
uint256 y;
function set(uint256 v) public returns (uint256) { x = v; return v; }
function f() public returns (uint256) {
(y, y, y) = (set(1), set(2), set(3));
return y;
}
}
Hi @Subway2023 , can you please check the below code, above you are assigning multiple values for same variable, below approach may fix the issue and returns value y=3.
```
contract C {
uint256 x;
uint256 y;
function set(uint256 v) public returns (uint256) {
x = v;
return v;
}
function f() public returns (uint256) {
uint256 a = set(1);
uint256 b = set(2);
uint256 c = set(3);
y = c;
return y;
}
}
``` pre>
Yes, the code you provided produces the correct answer. My goal is to expose the inconsistencies between solc and solang.
ok, got it