Consensys / surya

A set of utilities for exploring Solidity contracts
Apache License 2.0
1.06k stars 118 forks source link

Parse error with named mapping #179

Closed chalex-eth closed 10 months ago

chalex-eth commented 1 year ago

Hello,

When running some surya function such as inheritance or graph on solidity code (> 0.8.18) that implement mapping we get a parse error.

Let's say the following mapping

mapping(uint256 num1 => uint256 num2) myMapping;

Will result in

errors: [
    {
      message: "extraneous input 'num1' expecting '=>'",
      line: 61,
      column: 20
    },
    {
      message: "extraneous input 'num2' expecting ')'",
      line: 61,
      column: 45
    }
  ]
}
GNSPS commented 1 year ago

Hey @chalex-eth can you please try to uninstall surya and install again?

npm uninstall -g surya
npm install -g surya

The reason why I suggest this is because there is a floating dependency on the parser and it might just be an old parser version.

rashtrakoff commented 1 year ago

can you please try to uninstall surya and install again?

This doesn't work unfortunately ☚ī¸ . I converted the named mapping to a normal (unnamed) mapping and then it works as expected.

vittominacori commented 11 months ago

Same error using OpenZeppelin v5 ERC20 implementation that uses named mapping.

message: "extraneous input 'account' expecting '=>'",

tintinweb commented 10 months ago

ref: https://github.com/Consensys/vscode-solidity-auditor/issues/137

@GNSPS might require a parser update to v0.16.x

GNSPS commented 10 months ago

Updated! 🙏 Closing!

hexpaydaydev commented 10 months ago

did not work for me on first install. cleaning cache currently. we'll see if that helps


surya@^0.4.6:
  version "0.4.6"
  resolved "https://registry.yarnpkg.com/surya/-/surya-0.4.6.tgz#295a426eff219720d9b7963e04a50206288c321b"
  integrity sha512-zaTYkRbms26cuOWu5jon5l4OsToHX7ZEflqTozXgq/XxUL3VY+tEnxT9Te2WVsA/sYgZPwcH92yQZJgljsss4g==
  dependencies:
    "@solidity-parser/parser" "^0.14.1"
hexpaydaydev commented 10 months ago

ah, was a new version not published @GNSPS ?

hexpaydaydev commented 10 months ago

yup. 2 years ago: https://www.npmjs.com/package/surya

new pkg needs to be published to link it to solidity metrics and beyond

GNSPS commented 10 months ago

Yep, sorry, was waiting for a PR fix from myself for address member calls.

Published a new "patch" version: v0.4.7, can you try now? 🙏

hexpaydaydev commented 10 months ago

works! 🎉