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 10329 - Attributes not inferred for indirectly templated methods #2832

Merged
merged 4 commits into from
Jan 5, 2014

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Nov 20, 2013

https://d.puremagic.com/issues/show_bug.cgi?id=10329

This is the last step for the pure/@safe algorithms and ranges.

Except following two cases, all of instantiated function attributes will be inferred.

  1. Virtual methods

    class C(T) {
        void foo() {}
    }
    pragma(msg, typeof(&C!int.foo));    // void function()
  2. Non-eponymous functions which declared in template scope

    template X(T) {
        void foo(T) {}
    }
    pragma(msg, typeof(&X!int.foo));    // void function(int)

    (I'm not still sure this is an essential restriction, but currently it's necessary to avoid bug 10134).

After merging this PR, for example, following code will be runnable with git-head Phobos.

import std.algorithm, std.range;
void main() pure @safe
{
    int[][] ror =[[1,2,3]];
    auto r = joiner(ror);

    string res;
    foreach (e; chain("a", "b"))
        res ~= e;
    assert(res == "ab");
}

@@ -1803,7 +1802,7 @@ void FuncDeclaration::semantic3(Scope *sc)
f->deco = NULL;

// Do semantic type AFTER pure/nothrow inference.
if (!f->deco)
if (!f->deco && ident != Lexer::idPool("__xopEquals") && ident != Lexer::idPool("__xopCmp"))
Copy link
Member

Choose a reason for hiding this comment

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

I noticed in clone.c there's an idPool("_xopCmp") and idPool("__xopCmp"). I have no idea why there are two different identifiers. Also, having a third one suggests that it needs to be moved into idgen.c. Same for __xopEquals.

@9rnsr
Copy link
Contributor Author

9rnsr commented Nov 22, 2013

I moved two-underscore names __xopEquals and __xopCmp to idgen.c.

The two functions _xopEquals and _xopCmp exist in druntime object module. So I did select one underscored name, similarly to _ArrayEq function.

@WalterBright
Copy link
Member

Auto-merge toggled on

WalterBright added a commit that referenced this pull request Jan 5, 2014
Issue 10329 - Attributes not inferred for indirectly templated methods
@WalterBright WalterBright merged commit ebae884 into dlang:master Jan 5, 2014
@9rnsr
Copy link
Contributor Author

9rnsr commented Jan 6, 2014

Thanks!

@9rnsr 9rnsr deleted the fix10329 branch January 6, 2014 00:42
@monarchdodra
Copy link
Contributor

Most awesome.

9rnsr added a commit to 9rnsr/dmd that referenced this pull request Jan 13, 2014
This reverts commit ebae884, reversing
changes made to cd8a425.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants