Bug 9024 – Inferring function argument types from other template parameters

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-14T05:43:25Z
Last change time
2024-12-13T18:02:49Z
Assigned to
No Owner
Creator
Joseph Rushton Wakeling
See also
https://issues.dlang.org/show_bug.cgi?id=10228
Moved to GitHub: dmd#18492 →

Attachments

IDFilenameSummaryContent-TypeSize
1161infer.dMinimal source code with example of the issuetext/x-dsrc110

Comments

Comment #0 by joseph.wakeling — 2012-11-14T05:43:25Z
The attached code most likely ought to be valid according to the spec at http://dlang.org/template.html (point 2 under "Argument Deduction" states: "If the type specialization is dependent on a type parameter, the type of that parameter is set to be the corresponding part of the type argument"): struct Foo(_T) { alias _T T; } void func(T)(T foo, T.T x) { } void main() { Foo!int foo; func(foo, 3); } However, it fails to compile with an error infer.d(13): Error: undefined identifier T.T infer.d(13): Error: template infer.func does not match any function template declaration infer.d(13): Error: template infer.func(T) cannot deduce template function from argument types !()(Foo!(int),int) See discussion thread here: http://forum.dlang.org/post/[email protected] http://forum.dlang.org/post/[email protected] http://forum.dlang.org/post/[email protected] ... and also the following bug report where the issue is discussed: http://d.puremagic.com/issues/show_bug.cgi?id=9004
Comment #1 by joseph.wakeling — 2012-11-14T05:44:26Z
Created attachment 1161 Minimal source code with example of the issue
Comment #2 by nick — 2023-02-28T18:31:08Z
Different error now: tempspecinner.d(13): Error: none of the overloads of template `tempspecinner.func` are callable using argument types `!()(Foo!int, int)` tempspecinner.d(6): Candidate is: `func(T)(T foo, T.T x)`
Comment #3 by robert.schadek — 2024-12-13T18:02:49Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18492 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB