Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception on small source #6

Closed
mrx23dot opened this issue Feb 3, 2022 · 3 comments · Fixed by #7
Closed

Exception on small source #6

mrx23dot opened this issue Feb 3, 2022 · 3 comments · Fixed by #7

Comments

@mrx23dot
Copy link

mrx23dot commented Feb 3, 2022

solgrep dummy.sol --find="function.name"

gives

/usr/local/lib/node_modules/solgrep/src/rules/builtin.js:33
            return p.replaceAll(remapFunction, '_function.')
                     ^
TypeError: p.replaceAll is not a function
    at /usr/local/lib/node_modules/solgrep/src/rules/builtin.js:33:22
    at Array.map (<anonymous>)
    at GenericGrep._normalizePatterns (/usr/local/lib/node_modules/solgrep/src/rules/builtin.js:29:20)
    at new GenericGrep (/usr/local/lib/node_modules/solgrep/src/rules/builtin.js:23:30)
    at main (/usr/local/lib/node_modules/solgrep/bin/main.js:90:30)
    at Object.<anonymous> (/usr/local/lib/node_modules/solgrep/bin/main.js:161:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)

tested on windows/linux
SolGrep v0.0.7

installed with
sudo npm install solgrep -g

simple source
dummy.zip

stats works, but everything else fails, like --find="function.name == 'fallback'"

@tintinweb
Copy link
Owner

🤔 cannot reproduce

image

you can match the fallback function with:

function.isFallback == 'true' or function.name == '__fallback__' (similar for constructor)

Here're some fields you can test for:

      │     ├─ visibility: default
      │     ├─ modifiers
      │     ├─ override
      │     ├─ isConstructor: false
      │     ├─ isReceiveEther: false
      │     ├─ isFallback: false
      │     ├─ isVirtual: false
      │     └─ stateMutability

@mrx23dot
Copy link
Author

mrx23dot commented Feb 8, 2022

I started up a brand new VPS at linode with debian10:

sudo apt update 
sudo apt install npm
# [email protected]
sudo npm install solgrep -g
solgrep --version # 0.0.7
nano dummy.sol    # added content
sudo solgrep dummy.sol --find="function.name" 
same error.

Internet says
"TypeError: replaceAll is not a function" it is likely due to the method not implemented/supported by the browser/npm version
String.prototype.replaceAll() method was added in ES2021/ES12. (2021 jun in npm)

Solution for anything older than 1year, changing:

posNumbString.replaceAll('-', 'i');
to
posNumbString.replace(/-/g, 'i');

https://discourse.threejs.org/t/replaceall-is-not-a-function/14585

Server OSs don't have the latest from everything, but stable versions.
Any chance you could swap these?

@mrx23dot
Copy link
Author

mrx23dot commented Feb 8, 2022

There is only one instance in the repo :)
some solution: https://stackoverflow.com/questions/1144783/how-to-replace-all-occurrences-of-a-string-in-javascript

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

Successfully merging a pull request may close this issue.

2 participants