Open 0xalpharush opened 1 year ago
Another example
'solc --version' running
'solc test3.sol --combined-json abi,ast,bin,bin-runtime,srcmap,srcmap-runtime,userdoc,devdoc,hashes --allow-paths .,/Users/alpharush' running
Compilation warnings/errors on test3.sol:
Error: Source file requires different compiler version (current compiler is 0.8.20+commit.a1b79de6.Darwin.appleclang) - note that nightly builds are considered to be strictly less than the released version
--> test3.sol:1:1:
|
1 | pragma solidity >=0.4.0 <0.7.0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Traceback (most recent call last):
File "/Users/alpharush/env/lib/python3.9/site-packages/crytic_compile/platform/solc.py", line 575, in _run_solc
ret: Dict = json.loads(stdout)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/alpharush/env/lib/python3.9/site-packages/slither/__main__.py", line 814, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "/Users/alpharush/env/lib/python3.9/site-packages/slither/__main__.py", line 91, in process_all
compilations = compile_all(target, **vars(args))
File "/Users/alpharush/env/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 646, in compile_all
compilations.append(CryticCompile(target, **kwargs))
File "/Users/alpharush/env/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 131, in __init__
self._compile(**kwargs)
File "/Users/alpharush/env/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 553, in _compile
self._platform.compile(self, **kwargs)
File "/Users/alpharush/env/lib/python3.9/site-packages/crytic_compile/platform/solc.py", line 149, in compile
targets_json = _get_targets_json(compilation_unit, self._target, **kwargs)
File "/Users/alpharush/env/lib/python3.9/site-packages/crytic_compile/platform/solc.py", line 278, in _get_targets_json
return _run_solc(
File "/Users/alpharush/env/lib/python3.9/site-packages/crytic_compile/platform/solc.py", line 579, in _run_solc
raise InvalidCompilation(f"Invalid solc compilation {stderr}")
crytic_compile.platform.exceptions.InvalidCompilation: Invalid solc compilation Error: Source file requires different compiler version (current compiler is 0.8.20+commit.a1b79de6.Darwin.appleclang) - note that nightly builds are considered to be strictly less than the released version
--> test3.sol:1:1:
|
1 | pragma solidity >=0.4.0 <0.7.0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR:root:Error in test3.sol
ERROR:root:Traceback (most recent call last):
File "/Users/alpharush/env/lib/python3.9/site-packages/crytic_compile/platform/solc.py", line 575, in _run_solc
ret: Dict = json.loads(stdout)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/alpharush/env/lib/python3.9/site-packages/slither/__main__.py", line 814, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "/Users/alpharush/env/lib/python3.9/site-packages/slither/__main__.py", line 91, in process_all
compilations = compile_all(target, **vars(args))
File "/Users/alpharush/env/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 646, in compile_all
compilations.append(CryticCompile(target, **kwargs))
File "/Users/alpharush/env/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 131, in __init__
self._compile(**kwargs)
File "/Users/alpharush/env/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 553, in _compile
self._platform.compile(self, **kwargs)
File "/Users/alpharush/env/lib/python3.9/site-packages/crytic_compile/platform/solc.py", line 149, in compile
targets_json = _get_targets_json(compilation_unit, self._target, **kwargs)
File "/Users/alpharush/env/lib/python3.9/site-packages/crytic_compile/platform/solc.py", line 278, in _get_targets_json
return _run_solc(
File "/Users/alpharush/env/lib/python3.9/site-packages/crytic_compile/platform/solc.py", line 579, in _run_solc
raise InvalidCompilation(f"Invalid solc compilation {stderr}")
crytic_compile.platform.exceptions.InvalidCompilation: Invalid solc compilation Error: Source file requires different compiler version (current compiler is 0.8.20+commit.a1b79de6.Darwin.appleclang) - note that nightly builds are considered to be strictly less than the released version
--> test3.sol:1:1:
|
1 | pragma solidity >=0.4.0 <0.7.0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The PR removed too much info and impaired users debugging and reporting issues https://github.com/crytic/slither/issues/2525
I think we need to rethink this because it causes stuff like parser errors, wrong solc version, or any error in crytic-compile to be shown twice. It's very verbose and obfuscates the issue (e.g. it looks like it's a slither or crytic-compile error when in fact it may have to do with a missing comma in Solidity) https://github.com/crytic/slither/blob/3d4f934d3228f072b7df2c5e7252c64df4601bc8/slither/__main__.py#L873-L877
For example