-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Reports an error on unimplemented modifiers in a function definition. #11471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| contract A { | ||
| modifier m() virtual { _; } | ||
| } | ||
| abstract contract B is A { | ||
| modifier m() virtual override; | ||
| } | ||
| contract C is B { | ||
| function f() m public {} | ||
| } | ||
christianparpart marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+1
to
+9
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could use some positive test cases too (unless they already exist somewhere): Overriding unimplemented with unimplemented: abstract contract A {
modifier m() virtual;
}
abstract contract B is A {
modifier m() virtual override;
}
abstract contract C is B {
modifier m() virtual override;
function f() m public {}
}Leaving a modifier somewhere in the chain unimplemented through multiple inheritance: contract A {
modifier m() virtual { _; }
}
abstract contract B {
modifier m() virtual;
}
contract C is A, B {
modifier m() override(A, B) { _; }
function f() m public {}
}Use of an unimplemented modifier in an abstract contract: abstract contract A {
modifier m() virtual;
function f() m public {}
}
contract B is A {
modifier m() virtual override { _; }
}Use of an unimplemented modifier on a method that gets overridden: abstract contract A {
modifier m() virtual;
function f() m public virtual {}
}
abstract contract B is A {
function f() public override {}
}
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about these? Could you add them as tests? All but the second one are currently errors ( |
||
| // ---- | ||
| // TypeError 4593: (78-108): Overriding an implemented modifier with an unimplemented modifier is not allowed. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| contract A { | ||
| modifier m() virtual { _; } | ||
| } | ||
| abstract contract B { | ||
| modifier m() virtual; | ||
| } | ||
| contract C is A, B { | ||
| modifier m() override(A, B) { _; } | ||
| function f() m public {} | ||
| } | ||
| // ---- |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| abstract contract A { | ||
| modifier m() virtual; | ||
| } | ||
| abstract contract B is A { | ||
| modifier m() virtual override; | ||
| } | ||
| abstract contract C is B { | ||
| modifier m() virtual override; | ||
| function f() m public {} | ||
| } | ||
| // ---- |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| abstract contract A { | ||
| modifier m() virtual; | ||
| function f() m public {} | ||
| } | ||
| contract B is A { | ||
| modifier m() virtual override { _; } | ||
| } | ||
| // ---- |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| abstract contract A { | ||
| modifier m() virtual; | ||
| function f() m public virtual {} | ||
| } | ||
| abstract contract B is A { | ||
| function f() public override {} | ||
| } | ||
| // ---- |
Uh oh!
There was an error while loading. Please reload this page.