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
Issue 9199 - Module level qualified functions should be rejected #1400
Conversation
@@ -300,8 +300,8 @@ void FuncDeclaration::semantic(Scope *sc) | |||
if (isOverride() && !isVirtual()) | |||
error("cannot override a non-virtual function"); | |||
|
|||
if ((f->isConst() || f->isImmutable()) && !isThis()) | |||
error("without 'this' cannot be const/immutable"); | |||
if ((f->isConst() || f->isImmutable() || f->isShared() || f->isWild()) && !isThis()) |
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.
Faster version maybe?
if ((f->mod & (MODconst | MODimmutable | MODshared | MODwild)) && !isThis())
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 for your suggestion.
In this case, using (storage_class & STC_TYPECTOR) && !isThis()
is more short and identical.
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.
In this case, using (storage_class & STC_TYPECTOR) && !isThis() is more short and identical.
Sorry, this is incorrect...
Updated. |
LGTM. |
@9rnsr: Kenji, Issue 7252 fails because of an assert expecting errors in template.c ( alias const char* function() CFunc; I think such an alias should be disallowed because it seems to make the function const, and functions can't be const (only methods can). So it's somewhat related to this pull (function qualifiers). This pull doesn't fix it but maybe you want to have a go at it? Edit: Well it wouldn't entirely fix Issue 7252, because it asserts for const delegates too. But my point still stands. |
No, this is a valid alias declaration. The
Then bug 7252 is not related to bug 9199 IMO. |
Ah you're right, thanks. Anyway this pull passes tester and is ready for merging. |
Interesting new failure, it reports that a @safe function is inout. Possible regression caused by another pull? |
I had accidentally added code which contains the bug into Phobos (dlang/phobos#1073). |
Issue 9199 - Module level qualified functions should be rejected
http://d.puremagic.com/issues/show_bug.cgi?id=9199