D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11533 - Compiler should allow to being nested for static local template functions
Summary: Compiler should allow to being nested for static local template functions
Status: RESOLVED DUPLICATE of issue 5710
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2013-11-17 00:20 UTC by Kenji Hara
Modified: 2022-11-14 14:10 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kenji Hara 2013-11-17 00:20:56 UTC
Test case:

struct S
{
    void put(alias fun)() { fun!int(); }
}
void main()
{
    static void foo(T)() {}
    S s;
    s.put!foo();

    static void bar(alias fun)() { fun(); }
    void nested() {}
    bar!nested();
}

In main, foo and bar are static template function.
- When foo is instantiated in S.put, foo!int should not capture the frame of main function.
- When bar is instantiated in main, it should capture the frame of main function for the alias template parameter `fun`, but bar itself should not capture any frame.
Comment 2 github-bugzilla 2013-11-18 17:49:21 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/cfc81c56cd551bb366d978e9d016112ad8a6b6ea
fix Issue 11533 - Compiler should allow to being nested for static local template functions

https://github.com/D-Programming-Language/dmd/commit/07d776adfc8ded02da55805530c5f6dd454aee89
Merge pull request #2794 from 9rnsr/fix11533

Issue 11533 - Compiler should allow to being nested for static local template functions
Comment 3 Kenji Hara 2013-11-22 00:19:46 UTC
*** Issue 7805 has been marked as a duplicate of this issue. ***
Comment 4 ZombineDev 2016-03-15 16:32:42 UTC
I'm reopening because the test case doesn't work with DMD 2.070.2:

/d224/f50.d(11): Error: static function f50.main.bar!(nested).bar cannot access frame of function D main
/d224/f50.d(13): Error: template instance f50.main.bar!(nested) error instantiating
Comment 5 Kenji Hara 2016-03-15 23:06:10 UTC
(In reply to ZombineDev from comment #4)
> I'm reopening because the test case doesn't work with DMD 2.070.2:
> 
> /d224/f50.d(11): Error: static function f50.main.bar!(nested).bar cannot
> access frame of function D main
> /d224/f50.d(13): Error: template instance f50.main.bar!(nested) error
> instantiating

Oh, thanks for your reopen. The enhancement change was masked to _fix_ issue 11946.
https://github.com/D-Programming-Language/dmd/pull/3884
Comment 6 RazvanN 2022-11-14 14:10:55 UTC

*** This issue has been marked as a duplicate of issue 5710 ***