solang
solang copied to clipboard
[Inconsistent with solc]: Variable overriding a function causes unexpected execution results.
Solang version: v0.3.3-70-g32a45ea1 Description: Calling the foo function of contract X fails when using solc + EVM, but succeeds when using solang + SVM, returning 5 (which is an incorrect value).
contract A {
function foo() external virtual view returns(uint) { return 4; }
function foo(uint) external virtual view returns(uint) { return 4; }
function foo(uint, uint) external view virtual returns(uint) { return 4; }
}
contract X is A {
uint public override foo = 5;
}
Yes, we can simply change the variable name foo to avoid conflict with the inherited function. If the intention is to return the value 5, the correct approach is to override the foo() function in the derived contract and return 5 from the function instead of declaring a conflicting public variable.
Thank you very much, this is a great solution to correct result. Similar to other issues, another purpose of mine is to test the differences between solc+evm and solang+svm.