truffle icon indicating copy to clipboard operation
truffle copied to clipboard

Json artifacts are not generated for top-level structures and enums.

Open montyly opened this issue 5 years ago • 4 comments
trafficstars

Hi,

Recently Solidity added the support for top-level structures and enums. Their corresponding AST are not correctly generated by Truffle during compilation, which prevents their analyses with Slither (and probably other third-parties).

Issue

Truffle does not generate the json artifacts related to top-level structures and enums.

Steps to Reproduce

$ cat truffle-config.js
module.exports = {
  compilers: {
    solc: {
      version: "0.6.9"
    }
  }
}

$ cat contracts/A.sol
import "./Struct.sol";

contract A{
    St s;
}

$ cat contracts/Struct.sol

struct St{
    uint a;
}

$ truffle compile

Expected Behavior

The build directory should contain a json file with the StructDefinition for St's AST.

Actual Results

Only the AST of the contract A is present, and the AST of St is missing

Environment

Truffle v5.1.31 (core: 5.1.31)
Node v12.18.0

montyly avatar Jun 24 '20 17:06 montyly

@montyly thanks for bringing this up! A workaround for now is to make sure there is a contract in the same file. YMMV. We are working on a solution to this that is more elegant/helpful.

fainashalts avatar Jun 24 '20 18:06 fainashalts

Would it be possible for truffle to emit a warning if one of the top-level element does not generate a json artifact?

As we are seeing more and more codebase using this pattern, it breaks many analyses with Slither.

montyly avatar Nov 05 '20 14:11 montyly

@montyly yep, this is a good idea. Would you mind opening a separate issue for just the warning? That way it won't get lost

gnidan avatar Nov 05 '20 16:11 gnidan

Would it be possible to revisit fixing this issue as it negatively impacts the experience of truffle users who want to use Slither? https://github.com/crytic/slither/issues/1834#issuecomment-1500868916

0xalpharush avatar Apr 10 '23 15:04 0xalpharush