Skip to content

Commit 7bebcb7

Browse files
committed
prepare_report.js: Print ERROR in case of an exception during compilation instead of failing
- Our v0.4.11 release raises an exception on some LLL snippets containing returnlll (extracted from its end-to-end tests). - The report comparison will fail anyway because emscripten prints an abort code to stdout in that case but at least we'll be able to continue if we're comparing multiple versions.
1 parent 17fe96c commit 7bebcb7

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

scripts/bytecodecompare/prepare_report.js

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,41 @@ for (const optimize of [false, true])
5252
if (!stripSMTPragmas)
5353
input['settings']['modelChecker'] = {engine: 'none'}
5454

55-
const result = JSON.parse(compiler.compile(JSON.stringify(input)))
55+
let serializedOutput
56+
let result
57+
const serializedInput = JSON.stringify(input)
5658

5759
let internalCompilerError = false
58-
if ('errors' in result)
60+
try
5961
{
60-
for (const error of result['errors'])
61-
// JSON interface still returns contract metadata in case of an internal compiler error while
62-
// CLI interface does not. To make reports comparable we must force this case to be detected as
63-
// an error in both cases.
64-
if (['UnimplementedFeatureError', 'CompilerError', 'CodeGenerationError'].includes(error['type']))
65-
{
66-
internalCompilerError = true
67-
break
68-
}
62+
serializedOutput = compiler.compile(serializedInput)
63+
}
64+
catch (exception)
65+
{
66+
internalCompilerError = true
67+
}
68+
69+
if (!internalCompilerError)
70+
{
71+
result = JSON.parse(serializedOutput)
72+
73+
if ('errors' in result)
74+
for (const error of result['errors'])
75+
// JSON interface still returns contract metadata in case of an internal compiler error while
76+
// CLI interface does not. To make reports comparable we must force this case to be detected as
77+
// an error in both cases.
78+
if (['UnimplementedFeatureError', 'CompilerError', 'CodeGenerationError'].includes(error['type']))
79+
{
80+
internalCompilerError = true
81+
break
82+
}
6983
}
7084

7185
if (
86+
internalCompilerError ||
7287
!('contracts' in result) ||
7388
Object.keys(result['contracts']).length === 0 ||
74-
Object.keys(result['contracts']).every(file => Object.keys(result['contracts'][file]).length === 0) ||
75-
internalCompilerError
89+
Object.keys(result['contracts']).every(file => Object.keys(result['contracts'][file]).length === 0)
7690
)
7791
// NOTE: do not exit here because this may be run on source which cannot be compiled
7892
console.log(filename + ': <ERROR>')

0 commit comments

Comments
 (0)