[Issue 16655] lambda with type alias parameter fails std.traits.isSomeFunction

2016-11-02 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16655

ag0ae...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||ag0ae...@gmail.com
 Resolution|--- |INVALID

--- Comment #3 from ag0ae...@gmail.com ---
(In reply to Nick Treleaven from comment #0)
> The static asserts below fail:
> 
> struct Color {struct Red {}}
> 
> unittest {
>   import std.traits;
> 
>   alias ls = (string) => "string";
>   static assert(isSomeFunction!ls);
> 
>   with (Color) {
>   alias lc = (Red) => "red";
>   static assert(isSomeFunction!lc);
>   }
> }

This is a gotcha, but it's not a bug. In a function literal, a single
identifier is interpreted as the name of the parameter, not the type. So
`string` and `Red` do not refer to the types of the same names, but they're
parameter names. Consequently, ls and lc are not functions, but templates,
because the parameters are not typed yet.

Closing as invalid. Please reopen if I'm missing something.

--


[Issue 16655] lambda with type alias parameter fails std.traits.isSomeFunction

2016-11-02 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16655

--- Comment #2 from Nick Treleaven  ---
BTW parameter names aren't needed because the lambdas are used for
Algebraic().visit!Lambdas:
http://forum.dlang.org/post/pggfdcttxdpernjbx...@forum.dlang.org

--


[Issue 16655] lambda with type alias parameter fails std.traits.isSomeFunction

2016-11-02 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16655

--- Comment #1 from Nick Treleaven  ---
Workaround is to add parameter names:

alias ls = (string s) => "string";
alias lc = (Red r) => "red";

--