Bug 8575 – Lambda expression causes compilation error with template function

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-08-21T09:05:00Z
Last change time
2012-10-27T07:58:58Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
zan77137

Comments

Comment #0 by zan77137 — 2012-08-21T09:05:50Z
This code doesn't work! ------------ template tfunc(fun...) { auto tfunc(U)(U r) { return r; } } void bar(T)(T x) { // import std.functional; x.tfunc!(unaryFun!"a"); // <- OK x.tfunc!(a=>a); // <- NG } void test() { bar(uint.init); } void main() { bar(int.init); } ------------ RESULT ------------ $ dmd -run main Error: function main.bar!(uint).bar.tfunc!(__lambda2).tfunc!(int).tfunc is a nested function and cannot be accessed from main.bar!(int).bar ------------
Comment #1 by k.hara.pg — 2012-10-02T03:57:08Z
Comment #2 by github-bugzilla — 2012-10-27T07:04:57Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/688f7ce593eef75997a2b8f2527d3cd9338692aa fix Issue 8575 - Lambda expression causes compilation error with template function Template lambda is an expression, so we should keep FuncExp until actually starting instantiation of passed template instance. https://github.com/D-Programming-Language/dmd/commit/8b82a0aa4feb863e9bbc53b36cc2008a7d994696 Merge pull request #1158 from 9rnsr/fix8575 fix Issue 8575 - Lambda expression causes compilation error with template function
Comment #3 by yebblies — 2012-10-27T07:41:47Z
Fixed for D2
Comment #4 by k.hara.pg — 2012-10-27T07:50:56Z
(In reply to comment #3) > Fixed for D2 Lambda literal is only in D2. So we should mark this "RESOLVED FIXED".
Comment #5 by yebblies — 2012-10-27T07:58:58Z
Heh, the online documentation disagrees, but you're right.