solhint
solhint copied to clipboard
The specified node does not exist
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
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.
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
We have similar but different issues, there both should be resolved after upgrading dependency @solidity-parser/parser
.
@fvictorio when do you think we could do this?
It seems like I don't have write permission for this repo anymore.
@cmalfesi could you change that?
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 thanks!
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"
},
...
}
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
.