mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
prepare_report: Handle internal compiler errors in Standard JSON as errors, not missing bytecode
This commit is contained in:
@@ -46,10 +46,25 @@ for (const optimize of [false, true])
|
||||
|
||||
const result = JSON.parse(compiler.compile(JSON.stringify(input)))
|
||||
|
||||
let internalCompilerError = false
|
||||
if ('errors' in result)
|
||||
{
|
||||
for (const error of result['errors'])
|
||||
// JSON interface still returns contract metadata in case of an internal compiler error while
|
||||
// CLI interface does not. To make reports comparable we must force this case to be detected as
|
||||
// an error in both cases.
|
||||
if (['UnimplementedFeatureError', 'CompilerError', 'CodeGenerationError'].includes(error['type']))
|
||||
{
|
||||
internalCompilerError = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
!('contracts' in result) ||
|
||||
Object.keys(result['contracts']).length === 0 ||
|
||||
Object.keys(result['contracts']).every(file => Object.keys(result['contracts'][file]).length === 0)
|
||||
Object.keys(result['contracts']).every(file => Object.keys(result['contracts'][file]).length === 0) ||
|
||||
internalCompilerError
|
||||
)
|
||||
// NOTE: do not exit here because this may be run on source which cannot be compiled
|
||||
console.log(filename + ': <ERROR>')
|
||||
|
||||
@@ -73,10 +73,19 @@ def load_source(path: Union[Path, str], smt_use: SMTUse) -> str:
|
||||
def parse_standard_json_output(source_file_name: Path, standard_json_output: str) -> FileReport:
|
||||
decoded_json_output = json.loads(standard_json_output.strip())
|
||||
|
||||
# JSON interface still returns contract metadata in case of an internal compiler error while
|
||||
# CLI interface does not. To make reports comparable we must force this case to be detected as
|
||||
# an error in both cases.
|
||||
internal_compiler_error = any(
|
||||
error['type'] in ['UnimplementedFeatureError', 'CompilerError', 'CodeGenerationError']
|
||||
for error in decoded_json_output.get('errors', {})
|
||||
)
|
||||
|
||||
if (
|
||||
'contracts' not in decoded_json_output or
|
||||
len(decoded_json_output['contracts']) == 0 or
|
||||
all(len(file_results) == 0 for file_name, file_results in decoded_json_output['contracts'].items())
|
||||
all(len(file_results) == 0 for file_name, file_results in decoded_json_output['contracts'].items()) or
|
||||
internal_compiler_error
|
||||
):
|
||||
return FileReport(file_name=source_file_name, contract_reports=None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user