solhint icon indicating copy to clipboard operation
solhint copied to clipboard

The specified node does not exist

Open pmdaly opened this issue 3 years ago • 8 comments

Solhint does not seem to be working correctly when I lint from the command line. Installed via brew and linted with solhint test.sol.

Solhint version 3.3.6 OSX Monterey Apple M1 Pro

/opt/homebrew/lib/node_modules/solhint/lib/index.js:40
      throw e
      ^

Error: The specified node does not exist
    at FileLevelConstantContext.getChild (/opt/homebrew/lib/node_modules/solhint/node_modules/@solidity-parser/parser/dist/index.cjs.js:9354:15)
    at FileLevelConstantContext.getRuleContext (/opt/homebrew/lib/node_modules/solhint/node_modules/@solidity-parser/parser/dist/index.cjs.js:9417:19)
    at FileLevelConstantContext.identifier (/opt/homebrew/lib/node_modules/solhint/node_modules/@solidity-parser/parser/dist/index.cjs.js:32322:17)
    at ASTBuilder.visitFileLevelConstant (/opt/homebrew/lib/node_modules/solhint/node_modules/@solidity-parser/parser/dist/index.cjs.js:36176:22)
    at FileLevelConstantContext.accept (/opt/homebrew/lib/node_modules/solhint/node_modules/@solidity-parser/parser/dist/index.cjs.js:32345:22)
    at ASTBuilder.visit (/opt/homebrew/lib/node_modules/solhint/node_modules/@solidity-parser/parser/dist/index.cjs.js:17669:19)
    at /opt/homebrew/lib/node_modules/solhint/node_modules/@solidity-parser/parser/dist/index.cjs.js:35327:59
    at Array.map (<anonymous>)
    at ASTBuilder.visitSourceUnit (/opt/homebrew/lib/node_modules/solhint/node_modules/@solidity-parser/parser/dist/index.cjs.js:35327:39)
    at SourceUnitContext.accept (/opt/homebrew/lib/node_modules/solhint/node_modules/@solidity-parser/parser/dist/index.cjs.js:31855:22)

Node.js v17.2.0

pmdaly avatar Jan 31 '22 03:01 pmdaly

I had the same error, check if your file is ok, you don't have unmatching brackets or something weird. Run the command this way:

npx solhint 'contracts/**/*.sol'

I hope it solves your problem.

This is not as smart as eslint and if the code doesn't compile it's going to throw "The specified node does not exist" error.

brianunlam avatar Feb 03 '22 19:02 brianunlam

Having the similar exception, btw we're using user-defined types in project (if this could be a reason):

/Users/k06a/Projects/uniswap-v4-core/node_modules/solhint/lib/index.js:40
      throw e
      ^

Error: The specified node does not exist
    at StateVariableDeclarationContext.getChild (/Users/k06a/Projects/uniswap-v4-core/node_modules/@solidity-parser/parser/dist/index.cjs.js:9354:15)
    at StateVariableDeclarationContext.getRuleContext (/Users/k06a/Projects/uniswap-v4-core/node_modules/@solidity-parser/parser/dist/index.cjs.js:9417:19)
    at StateVariableDeclarationContext.identifier (/Users/k06a/Projects/uniswap-v4-core/node_modules/@solidity-parser/parser/dist/index.cjs.js:32243:17)
    at ASTBuilder.visitStateVariableDeclaration (/Users/k06a/Projects/uniswap-v4-core/node_modules/@solidity-parser/parser/dist/index.cjs.js:35351:22)
    at StateVariableDeclarationContext.accept (/Users/k06a/Projects/uniswap-v4-core/node_modules/@solidity-parser/parser/dist/index.cjs.js:32308:22)
    at ASTBuilder.visit (/Users/k06a/Projects/uniswap-v4-core/node_modules/@solidity-parser/parser/dist/index.cjs.js:17669:19)
    at ASTBuilder.visitContractPart (/Users/k06a/Projects/uniswap-v4-core/node_modules/@solidity-parser/parser/dist/index.cjs.js:35334:17)
    at ContractPartContext.accept (/Users/k06a/Projects/uniswap-v4-core/node_modules/@solidity-parser/parser/dist/index.cjs.js:32232:22)
    at ASTBuilder.visit (/Users/k06a/Projects/uniswap-v4-core/node_modules/@solidity-parser/parser/dist/index.cjs.js:17669:19)
    at /Users/k06a/Projects/uniswap-v4-core/node_modules/@solidity-parser/parser/dist/index.cjs.js:35344:52

Node.js v17.0.1

k06a avatar Feb 08 '22 15:02 k06a

We have similar but different issues, there both should be resolved after upgrading dependency @solidity-parser/parser.

k06a avatar Feb 08 '22 15:02 k06a

@fvictorio when do you think we could do this?

k06a avatar Feb 08 '22 15:02 k06a

It seems like I don't have write permission for this repo anymore.

@cmalfesi could you change that?

fvictorio avatar Feb 10 '22 12:02 fvictorio

Well, I'm still an owner of the package in npm, so I just published this fix. Upgrade to [email protected] to use the version that has the updated parser.

fvictorio avatar Feb 10 '22 12:02 fvictorio

@fvictorio thanks!

k06a avatar Feb 10 '22 13:02 k06a

Thanks for the 3.3.7 release! It solves some issues but solhint still breaks on using ... for ... global;. This can be fixed by upgrading @solidity-parser/parser from 0.14.1 to 0.14.2-beta.1.

Unless 3.3.8 is released it can be worked around by enforcing solhint to use the newer version, they cooperate flawlessly. For yarn it can be done by enforcing resolution in package.json:

{
    ...
    "resolutions": {
        "solhint/@solidity-parser/parser": "0.14.2-beta.1"
    },
    ...
}

CodeSandwich avatar Jun 08 '22 11:06 CodeSandwich

I just bumped into the same problem.

@fvictorio we might need another quick version bump for solhint to upgrade to the latest @solidity-parser/parser.

PaulRBerg avatar Oct 30 '22 16:10 PaulRBerg