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
Sorry for posting so many false positives, but this was the last one we found in our codebase that seemed to be erroneous. The unused-return detector seems to be tricked when using a ternary that calls a function inside a return statement. Since it seems that all three of those conditions must be true to trigger the erroneous detection, this seems like an edge case that can easily be avoided by slightly changing the syntax. Still, I thought it was worth creating a dummy example to demonstrate it:
/*
Test
*/
pragma solidity ^0.5.0;
library Math {
function add(uint a, uint b) internal pure returns (uint c) {
c = a + b;
}
function sub(uint a, uint b) internal pure returns (uint c) {
c = a - b;
}
}
contract TestContract {
using Math for uint;
uint public value;
constructor() public {
value = 0;
}
function updateValue(bool isAdd) external {
value = getUpdatedValue(isAdd);
}
function getUpdatedValue(bool isAdd) public view returns (uint) {
return isAdd ? value.add(1) : value.sub(1);
}
}
The text was updated successfully, but these errors were encountered:
Sorry for posting so many false positives, but this was the last one we found in our codebase that seemed to be erroneous. The
unused-return
detector seems to be tricked when using a ternary that calls a function inside a return statement. Since it seems that all three of those conditions must be true to trigger the erroneous detection, this seems like an edge case that can easily be avoided by slightly changing the syntax. Still, I thought it was worth creating a dummy example to demonstrate it:The text was updated successfully, but these errors were encountered: