-
Notifications
You must be signed in to change notification settings - Fork 7.9k
GH-16067: prevent invalid abstract
during compilation of methods
#16069
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
Conversation
Closes #16067, CC @iluuu1994 |
f0a1d74
to
2dcbfca
Compare
This is not really the right approach. Instead, what you should do is simply check in |
2dcbfca
to
c08b0ba
Compare
abstract
in methods of anonymous classesabstract
during compilation of methods
ABI break should be removed, no longer changes any header files |
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.
Thanks. The implementation now look more like I expected it to.
Zend/zend_compile.c
Outdated
// anonymous and can't be abstract | ||
const char *msg; | ||
if (ce->ce_flags & ZEND_ACC_ANON_CLASS) { | ||
msg = "Anonymous class %s cannot contain abstract method %s::%s"; |
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.
I'm not sure there's a point in printing the class name twice? I don't have a strong opinion on this. Maybe @kocsismate does?
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.
I'm not sure there is a point other, but I couldn't really figure out a better way to do it - the message is about the class not being allowed to have abstract methods, and then the method name is usually given with the class name too. What would you think of ...abstract method ::foo
without the class name?
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.
E.g. "Must not declare abstract method Foo::bar() in anonymous class" would be an option. But it's not a big deal.
f4a6b53
to
64bc13c
Compare
<rebased, GitHub was saying there was a merge conflict but |
So that it is clear what changes
For classes that are not declared `abstract`, produce a compiler error for any `abstract` methods. For anonymous classes, since they cannot be made abstract, the error message is slightly different.
64bc13c
to
8dbb886
Compare
Thank you @DanielEScherzer! |
For classes that are not declared
abstract
, produce a compiler error for anyabstract
methods. For anonymous classes and enums, since they cannot be made abstract, the error messages are slightly different.