www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17836] New: ICE with custom 'map' template

https://issues.dlang.org/show_bug.cgi?id=17836

          Issue ID: 17836
           Summary: ICE with custom 'map' template
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: elronnd protonmail.ch

This code causes an ICE in dmd and gdc.  Under LDC it compiles without errors
and when run it does exactly as expected:

void main() {
        import std.stdio;

        template mmap(alias fun) {
                void mmap(T...)(T list) {
                        foreach (item; list) {                                  
                                fun(item);
                        }
                }                                                               
        }


        void printstuffs(T...)(T args) {
                void printer(G)(G arg) {
                        writeln(arg);
                }

                mmap!printer(args);
        }


        printstuffs("bla", 7, 9.0);
}

--
Sep 17 2017