Bug 10945 – Type extracted in an 'is' expression in a constraint should be visible in the template body

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-01T16:50:00Z
Last change time
2013-09-01T17:00:34Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2013-09-01T16:50:44Z
Here's some interesting code another user has provided, with a reduced test-case: ----- struct Templ(Args...) { } struct WillWork(alias T) if (is(T : Templ!Args, Args...)) { static if (is(T : Templ!Args, Args...)) alias A = Args[0]; else static assert(0); } struct WontWork(alias T) if (is(T : Templ!Args, Args...)) { // Error: undefined identifier Args, did you mean alias T? alias A = Args[0]; } void main() { alias C = Templ!int; alias B = WillWork!C; B.A a; alias B2 = WontWork!C; // ng } ----- Note how the 'WillWork' template has to redundantly duplicate the constraint into a static if condition. It would be simpler if the body of the template had access to the types which were extracted with the 'is' expression in the template constraint. I can't think of any harm this would do, it would be beneficial. If the template is extracting the types like that, it probably wants something to do with those types in the template body.
Comment #1 by andrej.mitrovich — 2013-09-01T17:00:34Z
*** This issue has been marked as a duplicate of issue 6269 ***