Skip to content

Commit

Permalink
Perform ternary conditional injections before branch injections (#828)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgewecke authored Jan 25, 2024
1 parent 5aa1652 commit 7c0f13a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/instrumenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ class Instrumenter {
// Line instrumentation has to happen first
contract.injectionPoints[injectionPoint].sort((a, b) => {
const injections = [
'injectLogicalOR',
'injectBranch',
'injectOpenParen',
'injectOrFalse',
'injectAndTrue',
'injectEmptyBranch',
'injectLine'
];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pragma solidity ^0.7.0;

contract Test {
function a() public {
int i = 0;
if (false) {} else i == 0 ? i = 0 : i--;
}
}
4 changes: 4 additions & 0 deletions test/units/conditional.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,8 @@ describe('ternary conditionals', () => {
});
});

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

0 comments on commit 7c0f13a

Please sign in to comment.