www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6235] New: Regression(DMD 2.053) ICE on typeof(Range.init[0..$]) inside a templated struct/class

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6235

           Summary: Regression(DMD 2.053) ICE on typeof(Range.init[0..$])
                    inside a templated struct/class
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: sandford jhu.edu



This is a regression between DMD 2.052 and DMD 2.053. Here is a very reduced
test case:

struct Bug(Range) { pragma(msg, typeof(Range.init[0..$]) ); }

void main(string[] args) {
    Bug!(ubyte[]) bug;
}

The issue also effect classes and is statements, i.e.

    enum useSlicing = is(typeof(Range.init[0..$]) : const ubyte[] );

This problem seems to be limited to the use of a template parameter inside a
struct/class defined outside of the current scope. All of the following
compile:

void main(string[] args) {
    pragma(msg, typeof((ubyte[]).init[0..$]) );

    alias ubyte[] Range;
    pragma(msg, typeof(Range.init[0..$]) );

    struct NotBug(Range2) { pragma(msg, typeof(Range2.init[0..$]) ); }
    NotBug!(ubyte[]) notBug; 
}     

This bug can be worked around by placing the statement inside its own
sub-template. I.e:

struct Bug(Range) {
    template UseSlicing(__Range) {
        enum UseSlicing = is(typeof(__Range.init[0..$]) : const ubyte[] );
    }
    pragma(msg, UseSlicing!Range);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 01 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6235


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au



It's crashing in VoidInitializer::toDt(). Seems that 'type' hasn't been set.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 01 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6235


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com



Using $ seems to be adding the declaration to the struct as a field.
Is there any reason $ is always a variable, not just re-written as
exp[... $ ... ] => exp[... exp.length ...] ?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 01 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6235





 Using $ seems to be adding the declaration to the struct as a field.
 Is there any reason $ is always a variable, not just re-written as
 exp[... $ ... ] => exp[... exp.length ...] ?
I think it's because exp may have side effects, so it should only be evaluated once. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 03 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6235





 exp[... $ ... ] => exp[... exp.length ...] ?
I think it's because exp may have side effects, so it should only be evaluated once.
Ah, of course. Can you see anything wrong with rewriting it as: (auto __tmp = exp, __tmp[... __tmp.length ...]) I'll have to dig into it to be sure, but I think something like this would solve a lot of the problems caused by __dollar. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 04 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6235






 exp[... $ ... ] => exp[... exp.length ...] ?
I think it's because exp may have side effects, so it should only be evaluated once.
Ah, of course. Can you see anything wrong with rewriting it as: (auto __tmp = exp, __tmp[... __tmp.length ...])
Not sure. There might be problem if exp defines postblit.
 I'll have to dig into it to be sure, but I think something like this would
 solve a lot of the problems caused by __dollar.
-- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 04 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6235




Regression introduced by me:

https://github.com/D-Programming-Language/dmd/commit/03e022f8cbfed660d31ebe6217f3faab01ca7472

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 24 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6235


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



https://github.com/D-Programming-Language/dmd/commit/56d4a1bc4781837823665ef7423aa7e2b2df1083

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 03 2011