Bug 12285 – Allow local symbols in alias parameter to non-static templates when both have same scope

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-02T07:02:53Z
Last change time
2020-05-24T15:28:09Z
Keywords
pull
Assigned to
No Owner
Creator
Vladimir Panteleev
Blocks
12230

Comments

Comment #0 by dlang-bugzilla — 2014-03-02T07:02:53Z
///////// test.d //////// struct S { int a, c; template toA(alias s) { void copy() { a = s; } } alias cToA = toA!c; } unittest { S s; s.c = 42; s.cToA.copy(); assert(s.a == 42); } ///////////////////////// Currently, this produces: test.d(13): Error: template instance toA!(c) cannot use local 'c' as parameter to non-global template toA(alias s) Note that this restriction only applies to variables, but not methods, because of issue 12230. Fixing 12230 without merging this would surely break code (e.g. is std.regex, see set!setInvMask).
Comment #1 by dlang-bugzilla — 2014-03-02T12:31:10Z
Comment #2 by b2.temp — 2020-05-24T15:28:09Z
works since 2.087.1.