Skip to content

Multiline ternary chains don't instrument correctly #192

Closed
@chapati23

Description

@chapati23

Description

Both truffle compile (using global truffle) as well as yarn truffle compile (using local truffle) work. However, the second truffle compile that's running inside solidity-coverage throws an error during compilation and I don't understand how this could happen because it seems I'm using the same version everywhere. Is it an issue with the instrumentation?

Versions

macOS 10.13.3
node.js 9.4.0
truffle (global) 4.0.1 with solidity 0.4.18
truffle (local) 4.0.1 with solidity 0.4.18

The Error

This error occurs during the second compilation, if I understand solidity-coverage correctly, this means after instrumentation

smart-contracts/coverageEnv/contracts/Cov.sol:27:9: TypeError: Wrong argument count for function call: 2 arguments given but expected 1.
      : balances[_address]
        ^
Spanning multiple lines.

smart-contracts/coverageEnv/contracts/Cov.sol:25:81: TypeError: True expression's type tuple(tuple(),uint8) doesn't match false expression's type uint256.
uint256 _totalPerTokenUnclaimedConverted; (,_totalPerTokenUnclaimedConverted) = totalPerTokenPayout == 0
                                                                                ^

pasted_image_08_02_18__12_59

How To Reproduce

Here's a minimum contract to reproduce:

pragma solidity 0.4.18;

import "zeppelin-solidity/contracts/token/PausableToken.sol";

contract TestToken is PausableToken {
  uint256 public totalPerTokenPayout;
  mapping(address => uint256) public claimedPerTokenPayouts;

  function TestToken () public { }

  function currentPayout(address _address)
    public
    view
    returns (uint256)
  {
    uint256 _totalPerTokenUnclaimedConverted = totalPerTokenPayout == 0
      ? 0
      : balances[_address]
      .mul(totalPerTokenPayout.sub(claimedPerTokenPayouts[_address]))
      .div(1e18);

    return _totalPerTokenUnclaimedConverted;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions