-
Notifications
You must be signed in to change notification settings - Fork 199
Validate constructors in ancestor contracts #1385
Conversation
7d03411
to
5718f16
Compare
Funny thing. The And apparently Solidity generates an ABI entry for the constructor (even if it's internal), which is being picked up by the new validation, and causes the integration test to fail.
From the test log:
We'll have to think how to get around this. Perhaps adding an exception for the Context contract? Or checking if the ctor body is empty? |
Co-Authored-By: Francisco Giordano <[email protected]>
@@ -12,6 +12,6 @@ export function hasConstructor(contract: Contract, buildArtifacts: BuildArtifact | |||
function hasNonEmptyConstructorInAST(contractNode: any): boolean { | |||
return contractNode.nodes | |||
.filter((n: any) => n.nodeType === 'FunctionDefinition' && n.kind === 'constructor') | |||
.filter((n: any) => n.body.statements.length > 0) | |||
.filter((n: any) => n.body.statements.length > 0 || n.modifiers.length > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There can be false positives if there is a "modifier" that is a super call to a parent contract with an empty constructor. But that's an edge case that I don't think will happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! There's linter errors though.
Fixes #1332