Skip to content

Commit a7d9dcc

Browse files
committed
Do not treat inheritance constructors as branches
1 parent 2e1a230 commit a7d9dcc

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

lib/registrar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class Registrar {
129129
}
130130

131131
// Add modifier branch coverage
132-
if (!this.enabled.modifiers) continue;
132+
if (!this.enabled.modifiers || expression.isConstructor) continue;
133133

134134
this.addNewModifierBranch(contract, modifier);
135135
this._createInjectionPoint(
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pragma solidity ^0.7.0;
2+
3+
contract Parent {
4+
string public name;
5+
6+
constructor(string memory _name) public {
7+
name = _name;
8+
}
9+
}
10+
11+
contract Test is Parent {
12+
constructor() public Parent("Test") {}
13+
14+
function a() public {
15+
uint x = 5;
16+
}
17+
}

test/units/modifiers.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,10 @@ describe('modifiers', () => {
160160
1: 1, 2: 1, 3: 1
161161
});
162162
});
163+
164+
it('should *not* treat constructor inheritance invocations as branches', async function() {
165+
const mapping = await setupAndRun('modifiers/constructor');
166+
assert.deepEqual(mapping[util.filePath].b, {});
167+
});
168+
163169
});

0 commit comments

Comments
 (0)