Skip to content

Commit 7c0f13a

Browse files
authored
Perform ternary conditional injections before branch injections (#828)
1 parent 5aa1652 commit 7c0f13a

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

lib/instrumenter.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ class Instrumenter {
9696
// Line instrumentation has to happen first
9797
contract.injectionPoints[injectionPoint].sort((a, b) => {
9898
const injections = [
99-
'injectLogicalOR',
10099
'injectBranch',
100+
'injectOpenParen',
101+
'injectOrFalse',
102+
'injectAndTrue',
101103
'injectEmptyBranch',
102104
'injectLine'
103105
];
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pragma solidity ^0.7.0;
2+
3+
contract Test {
4+
function a() public {
5+
int i = 0;
6+
if (false) {} else i == 0 ? i = 0 : i--;
7+
}
8+
}

test/units/conditional.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,4 +229,8 @@ describe('ternary conditionals', () => {
229229
});
230230
});
231231

232+
it('should compile after instrumenting a ternary conditional which follows an unbracketed else', () => {
233+
const info = util.instrumentAndCompile('conditional/ternary-with-unbracketed-else');
234+
util.report(info.solcOutput.errors);
235+
});
232236
});

0 commit comments

Comments
 (0)