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 11533 - Compiler should allow to being nested for static local template functions #2794

Merged
merged 2 commits into from
Nov 19, 2013

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Nov 17, 2013

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

The enhancement will introduce more consistent semantics for "local but static template".

bar!nested();
}

/******************************************/
Copy link
Member

Choose a reason for hiding this comment

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

You might want to add a test case for a static template struct.

void test11533b()
{
    static struct Foo(alias fun)
    {
        auto call() { return fun(); }
    }
    int var = 1;
    auto getVar() { return var; }
    Foo!getVar foo;
    assert(foo.call() == var);
    var += 1;
    assert(foo.call() == var);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Done.

They won't be modified in semantic phase, so pass them by constructor arguments of `TemplateDeclaration`.
@MartinNowak
Copy link
Member

Auto-merge toggled on

@MartinNowak
Copy link
Member

We should still try to replace this with a proper fix to Issue 5710.
Also static local template functions can access variables of the outer frame iff the alias parameter requires nesting.

MartinNowak added a commit that referenced this pull request Nov 19, 2013
Issue 11533 - Compiler should allow to being nested for static local template functions
@MartinNowak MartinNowak merged commit 07d776a into dlang:master Nov 19, 2013
@9rnsr 9rnsr deleted the fix11533 branch November 20, 2013 00:41
@CyberShadow
Copy link
Member

This pull request introduced a regression: https://d.puremagic.com/issues/show_bug.cgi?id=11946

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