Issue 15499 - IFTI fails with function literal alias
Summary: IFTI fails with function literal alias
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2016-01-02 11:37 UTC by Daniel
Modified: 2024-11-11 04:39 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Daniel 2016-01-02 11:37:17 UTC
alias add1(T1,T2) = (T1 a, T2 b)       => a+b;
int   add2(T1,T2)   (T1 a, T2 b) { return a+b; }

void main()
{
  import std.stdio;
  add1(1,1).writeln; // cannot deduce function from argument types !()(int, int)
  add2(1,1).writeln; // OK
}
Comment 1 basile-z 2016-01-02 14:32:16 UTC
(In reply to Daniel from comment #0)
> alias add1(T1,T2) = (T1 a, T2 b)       => a+b;
> int   add2(T1,T2)   (T1 a, T2 b) { return a+b; }
> 
> void main()
> {
>   import std.stdio;
>   add1(1,1).writeln; // cannot deduce function from argument types !()(int,
> int)
>   add2(1,1).writeln; // OK
> }

It's maybe a dup of 1807.

I asked this a while ago on the forum (IFTI failed in partial template specialization).

http://forum.dlang.org/post/yhzadvyxijdyyoreatey@forum.dlang.org

=>

https://issues.dlang.org/show_bug.cgi?id=1807
Comment 2 Nick Treleaven 2023-08-26 11:38:03 UTC
> alias add1(T1,T2) = (T1 a, T2 b)       => a+b;
> int   add2(T1,T2)   (T1 a, T2 b) { return a+b; }

I think this should be changed to an enhancement, because add1 is a function literal template, whereas add2 is a function template. A function literal is a pointer, a function is not.