Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

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

Open
montyly opened this issue Jun 24, 2020 · 4 comments
Open

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

montyly opened this issue Jun 24, 2020 · 4 comments

Comments

@montyly
Copy link

montyly commented Jun 24, 2020

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
@fainashalts
Copy link
Contributor

@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.

@montyly
Copy link
Author

montyly commented Nov 5, 2020

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.

@gnidan
Copy link
Contributor

gnidan commented Nov 5, 2020

@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

@0xalpharush
Copy link

Would it be possible to revisit fixing this issue as it negatively impacts the experience of truffle users who want to use Slither? crytic/slither#1834 (comment)

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

No branches or pull requests

4 participants