prepare_report: Handle internal compiler errors in Standard JSON as errors, not missing bytecode

This commit is contained in:
Kamil Śliwak
2021-01-26 23:30:38 +01:00
parent f7007ea324
commit 53f9a11440
9 changed files with 176 additions and 2 deletions
+16 -1
View File
@@ -24,10 +24,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>')