defi-wonderland / natspec-smells

👃Automatically identify missing or incomplete natspec
MIT License
91 stars 7 forks source link

Does not recognize `payable` #32

Closed kopy-kat closed 5 months ago

kopy-kat commented 5 months ago

Example:

address payable constant SWAPROUTER_ADDRESS = payable(0xE592427A0AEce92De3Edee1F18E0157C05861564);

Error message:

CompileInferenceError: Failed parsing imports at [PATH/CONTRACT]:66:1 - Expected " ", "/*", "//", "[", "\t", "\x0B", "\x0C", "constant", " ", "", [ , , , - , , , ], or [\n,\r,
,
] but "p" found.
    at findAllFiles (/.../node_modules/.pnpm/solc-typed-ast@17.0.3_typescript@5.3.3/node_modules/solc-typed-ast/dist/compile/inference/imports.js:128:23)
    at compileSol (/.../node_modules/.pnpm/solc-typed-ast@17.0.3_typescript@5.3.3/node_modules/solc-typed-ast/dist/compile/utils.js:160:44)
    at async getProjectCompiledSources (/.../node_modules/.pnpm/@defi-wonderland+natspec-smells@1.0.3_typescript@5.3.3/node_modules/@defi-wonderland/natspec-smells/lib/utils.js:29:27)
    at async /.../node_modules/.pnpm/@defi-wonderland+natspec-smells@1.0.3_typescript@5.3.3/node_modules/@defi-wonderland/natspec-smells/lib/main.js:16:25
gas1cent commented 5 months ago

@kopy-kat hey, thanks for the report! What solidity version are you using? Any chance I can see the full contract?

kopy-kat commented 5 months ago

Using 0.8.24 and this is actually the full file (its in a lib):

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

address payable constant SWAPROUTER_ADDRESS = payable(0xE592427A0AEce92De3Edee1F18E0157C05861564);
uint24 constant SWAPROUTER_DEFAULTFEE = 3000;
gas1cent commented 5 months ago

Perfect, thanks. It seems to be a parser issue, I've reported it here: https://github.com/Consensys/solc-typed-ast/issues/255 Will update you once we find a solution.

gas1cent commented 5 months ago

Hey @kopy-kat! Just fyi, the bug has been addressed by the Consensys team and we've included the fix in v1.1.1. Give it a try :)