Skip to content

[Breaking] Remove virtual modifiers from the language - #17178

Open
blishko wants to merge 2 commits into
breaking-0.9from
remove-virtual-modifiers
Open

blishko wants to merge 2 commits into
breaking-0.9from
remove-virtual-modifiers

Conversation

@blishko

@blishko blishko commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Virtual modifiers has been deprecated and scheduled for removal. The mechanism of modifiers, in combination with inheritance is already quite complicated and allowing modifiers to be virtual as well complicates things further with little benefit.

From #12483 "Modifiers are already a very complicated concept and we should not make it more difficult by allowing them to be virtual. Except for weird cases (adding another placeholder, putting it inside a loop, ...), you can get the same behaviour by adding a virtual function that is called from the modifier."

@blishko blishko changed the title Remove virtual modifiers from the language [Breaking] Remove virtual modifiers from the language Nov 3, 2026
@blishko
blishko force-pushed the remove-virtual-modifiers branch 6 times, most recently from b4ea04c to f4cd946 Compare November 4, 2026 18:54
Comment on lines -318 to -320

for (ModifierDefinition const* modifier: contract->functionModifiers())
registerProxy(OverrideProxy(modifier));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modifiers cannot be unimplemented anymore, that's a syntax error now, so no need to check them here.

Comment on lines +212 to +213
if (!_modifier.isImplemented())
m_errorReporter.syntaxError(8063_error, _modifier.location(), "Modifiers without implementation are not allowed.");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I am changing the unimplemented modifier from a type error to syntax error. I think it makes more sense this way.

Comment on lines -632 to -640
if (
*_modifier.name().annotation().requiredLookup == VirtualLookup::Static &&
!modifierDecl->isImplemented()
)
m_errorReporter.typeError(
1835_error,
_modifier.location(),
"Cannot call unimplemented modifier. The modifier has no implementation in the referenced contract. Refer to it by its unqualified name if you want to call the implementation from the most derived contract."
);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need this check. Unimplemented modifier is a syntax error, I think that is sufficient.

};
if (!_node.annotation().baseFunctions.empty())
attributes.emplace_back(std::make_pair("baseModifiers", getContainerIds(_node.annotation().baseFunctions, true)));
solAssert(_node.annotation().baseFunctions.empty());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not not 100% sure about this, we should double-check.

@blishko
blishko marked this pull request as ready for review November 5, 2026 08:35
Virtual modifiers has been deprecated and scheduled for removal.
The mechanism of modifiers, in combination with inheritance is already
quite complicated and allowing modifiers to be virtual as well
complicates things further with little benefit.

From #12483
"Modifiers are already a very complicated concept and we should not make
it more difficult by allowing them to be virtual. Except for weird cases
(adding another placeholder, putting it inside a loop, ...), you can get
the same behaviour by adding a virtual function that is called from the
modifier."
@blishko
blishko force-pushed the remove-virtual-modifiers branch from 66b9866 to 2fb3743 Compare November 9, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant