Skip to content
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

Errors reported for modifier overloading should outright say that overloading is not allowed #12332

Closed
cameel opened this issue Nov 25, 2021 · 12 comments
Labels
closed due inactivity The issue/PR was automatically closed due to inactivity. good first issue candidate Could be a "good first issue" but something is blocking it or it has open questions. low impact Changes are not very noticeable or potential benefits are limited. medium effort Default level of effort should have We like the idea but it’s not important enough to be a part of the roadmap. should report better error Error is just badly reported. Should be a proper type error - source is not fine. stale The issue/PR was marked as stale because it has been open for too long.

Comments

@cameel
Copy link
Member

cameel commented Nov 25, 2021

Error messages reported when you try to overload a modifier say that you cannot use the same name but do not say why. I think they should outright say that the cause of the error is that modifier overloading is not allowed. At least until we actually implement it (#72).

Example 1: straightforward overloading

contract C {
    modifier m(uint x) { _; }
    modifier m() { _; }
}
Error: Identifier already declared.
 --> test.sol:3:5:
  |
3 |     modifier m() { _; }
  |     ^^^^^^^^^^^^^^^^^^^
Note: The previous declaration is here:
 --> test.sol:2:5:
  |
2 |     modifier m(uint x) { _; }
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^

Example 2: overloading by inheriting from two bases

contract A {
    modifier m() { _; }
}
contract B {
    modifier m(uint x) { _; }
}
contract C is B, A {}

This case is especially misleading because the message suggests that you should override the modifiers in the derived class but they aren't even virtual.

Error: Derived contract must override modifier "m". Two or more base classes define modifier with same name.
 --> test.sol:7:1:
  |
7 | contract C is B, A {
  | ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "A":
 --> test.sol:2:5:
  |
2 |     modifier m() { _; }
  |     ^^^^^^^^^^^^^^^^^^^
Note: Definition in "B":
 --> test.sol:5:5:
  |
5 |     modifier m(uint x) { _; }
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^
@cameel cameel added enhancement medium difficulty should report better error Error is just badly reported. Should be a proper type error - source is not fine. good first issue candidate Could be a "good first issue" but something is blocking it or it has open questions. labels Nov 25, 2021
@cameel cameel added this to New issues in Solidity via automation Nov 25, 2021
@elijahhampton

This comment was marked as off-topic.

@cameel cameel added good first issue and removed good first issue candidate Could be a "good first issue" but something is blocking it or it has open questions. labels Jan 12, 2022
@cameel

This comment was marked as off-topic.

@0xGeorgii

This comment was marked as off-topic.

@cameel

This comment was marked as off-topic.

@0xGeorgii

This comment was marked as off-topic.

@cameel

This comment was marked as off-topic.

@cameel cameel added good first issue candidate Could be a "good first issue" but something is blocking it or it has open questions. medium effort Default level of effort low impact Changes are not very noticeable or potential benefits are limited. should have We like the idea but it’s not important enough to be a part of the roadmap. and removed good first issue medium difficulty labels Nov 10, 2022
@0xGeorgii

This comment was marked as off-topic.

@cameel

This comment was marked as off-topic.

@github-actions
Copy link

This issue has been marked as stale due to inactivity for the last 90 days.
It will be automatically closed in 7 days.

@github-actions github-actions bot added the stale The issue/PR was marked as stale because it has been open for too long. label Mar 21, 2023
@cameel
Copy link
Member Author

cameel commented Mar 22, 2023

Bad error messages are an annoyance that I'd really like to see fixed. Maybe we should create a catch-all issue for this but until then, I'm going to keep this one open.

@github-actions github-actions bot removed the stale The issue/PR was marked as stale because it has been open for too long. label Mar 23, 2023
@github-actions
Copy link

This issue has been marked as stale due to inactivity for the last 90 days.
It will be automatically closed in 7 days.

@github-actions github-actions bot added the stale The issue/PR was marked as stale because it has been open for too long. label Jun 22, 2023
@github-actions
Copy link

Hi everyone! This issue has been automatically closed due to inactivity.
If you think this issue is still relevant in the latest Solidity version and you have something to contribute, feel free to reopen.
However, unless the issue is a concrete proposal that can be implemented, we recommend starting a language discussion on the forum instead.

@github-actions github-actions bot added the closed due inactivity The issue/PR was automatically closed due to inactivity. label Jun 29, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed due inactivity The issue/PR was automatically closed due to inactivity. good first issue candidate Could be a "good first issue" but something is blocking it or it has open questions. low impact Changes are not very noticeable or potential benefits are limited. medium effort Default level of effort should have We like the idea but it’s not important enough to be a part of the roadmap. should report better error Error is just badly reported. Should be a proper type error - source is not fine. stale The issue/PR was marked as stale because it has been open for too long.
Projects
None yet
Development

No branches or pull requests

4 participants