Skip to content

Instrumentation fails on multiple ternary operators in one expression #751

Closed
@ZumZoom

Description

@ZumZoom
function bounded(uint256 value, uint256 min, uint256 max) private pure returns (uint256) {
    return value < min ? min : value > max ? max : value;
}

Instrumenting this code with solidity-coverage fails with errors like these:

TypeError: True expression's type uint256 does not match false expression's type bool.
  --> contracts/MVP.sol:43:10:
   |
43 | return ((((value < min && c_trueceeaad3d(0xb57143507adc733b)) || c_falseceeaad3d(0x92234262f887204f)) ? min : value > max && c_trueceeaad3d(0x5923ce7a7e1a34e5)) || c_falseceeaad3d(0x8ad90b3a2b2c ...
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


TypeError: Operator || not compatible with types uint256 and bool
  --> contracts/MVP.sol:43:9:
   |
43 | return ((((value < min && c_trueceeaad3d(0x ... c_falseceeaad3d(0x8ad90b3a2b2c4f8a)) ? max : value;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


TypeError: Type uint256 is not implicitly convertible to expected type bool.
  --> contracts/MVP.sol:43:8:
   |
43 | return ((((value < min && c_trueceeaad3d(0 ... _falseceeaad3d(0x8ad90b3a2b2c4f8a)) ? max : value;
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


Error in plugin solidity-coverage: HardhatError: HH600: Compilation failed

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions