Bug 7805 – "static" allows free templated functions to accept struct fields as template alias parameters

Status
REOPENED
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-31T07:20:50Z
Last change time
2024-12-13T17:59:22Z
Keywords
pull
Assigned to
No Owner
Creator
Vladimir Panteleev
Moved to GitHub: dmd#17545 →

Comments

Comment #0 by dlang-bugzilla — 2012-03-31T07:20:50Z
//static string f(alias X)() { return null; } struct S { int i; mixin(f!i()); } This program doesn't compile, however uncommenting "static" makes it work. DMD 2.058 produces this error message: test.d(8): Error: struct test.S no size yet for forward reference DMD git produces a different error message: test.d(2): Error: function test.S.f!(i).f need 'this' to access member f Note that fixing this issue by making both cases fail to compile would break code. I believe the Orange serialization library uses this trick to stringify field names with minimal syntax overhead.
Comment #1 by k.hara.pg — 2013-11-22T00:19:46Z
Fixed by issue 11533. *** This issue has been marked as a duplicate of issue 11533 ***
Comment #2 by k.hara.pg — 2014-01-20T03:40:06Z
I reopen this issue as an enhancement request. https://github.com/D-Programming-Language/dmd/pull/3126
Comment #3 by robert.schadek — 2024-12-13T17:59:22Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17545 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB