Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instrumentation fails on multiple ternary operators in one expression #751

Closed
ZumZoom opened this issue Sep 20, 2022 · 3 comments · Fixed by #829
Closed

Instrumentation fails on multiple ternary operators in one expression #751

ZumZoom opened this issue Sep 20, 2022 · 3 comments · Fixed by #829

Comments

@ZumZoom
Copy link
Contributor

ZumZoom commented Sep 20, 2022

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
@ZumZoom ZumZoom changed the title Instrumentation fails with multiple ternary operators in one expression Instrumentation fails on multiple ternary operators in one expression Sep 20, 2022
@m1cm1c
Copy link

m1cm1c commented May 3, 2023

Same problem. Experienced it on Manjaro with the following versions:

  • hardhat@2.14.0
  • solidity-coverage@0.8.2
  • npx version 8.15.0
  • node version v16.17.0

@cgewecke
Copy link
Member

Not sure this is fixed yet ... sorry.

@cgewecke
Copy link
Member

Fixed in 0.8.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants