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

Issue 9199 - Module level qualified functions should be rejected #1400

Merged
merged 2 commits into from Feb 18, 2013

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Dec 23, 2012

@@ -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())
Copy link

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())

Copy link
Contributor Author

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.

Copy link
Contributor Author

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...

@9rnsr
Copy link
Contributor Author

9rnsr commented Dec 24, 2012

Updated.

@ghost
Copy link

ghost commented Dec 24, 2012

LGTM.

@ghost
Copy link

ghost commented Dec 24, 2012

@9rnsr: Kenji, Issue 7252 fails because of an assert expecting errors in template.c (assert(global.errors);), but I think the real problem could be the alias in the sample:

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.

@9rnsr
Copy link
Contributor Author

9rnsr commented Dec 25, 2012

alias const char* function() CFunc;

No, this is a valid alias declaration. The const affects to a function pointer type, not a function. So it is identical with:

alias const (char* function()) CFunc;

Then bug 7252 is not related to bug 9199 IMO.

@ghost
Copy link

ghost commented Dec 25, 2012

Ah you're right, thanks. Anyway this pull passes tester and is ready for merging.

@ghost
Copy link

ghost commented Jan 18, 2013

Interesting new failure, it reports that a @safe function is inout. Possible regression caused by another pull?

@9rnsr
Copy link
Contributor Author

9rnsr commented Jan 22, 2013

I had accidentally added code which contains the bug into Phobos (dlang/phobos#1073).
To fix the problem I opened a new pull dlang/phobos#1087.

9rnsr added a commit that referenced this pull request Feb 18, 2013
Issue 9199 - Module level qualified functions should be rejected
@9rnsr 9rnsr merged commit a22a125 into dlang:master Feb 18, 2013
@9rnsr 9rnsr deleted the fix9199 branch February 18, 2013 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant