Thread overview
[Issue 9547] New: typeof() which requires .init must be properly documented
Feb 20, 2013
Andrej Mitrovic
Feb 20, 2013
Andrej Mitrovic
Feb 20, 2013
Andrej Mitrovic
Feb 20, 2013
Kenji Hara
Feb 20, 2013
Andrej Mitrovic
Sep 17, 2013
Andrej Mitrovic
February 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9547

           Summary: typeof() which requires .init must be properly
                    documented
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: spec
          Severity: regression
          Priority: P2
         Component: websites
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-19 20:46:48 PST ---
import std.range;

void getArray(T)()
{
    alias ElementType!T ElemType1;  // OK
    alias typeof(T[0]) ElemType2;   // NG
}

void main()
{
    getArray!(string[])();
}

This worked in 2.061, and broke LuaD in 2.062. The workaround (or rather the
new valid code) is:

alias typeof(T.init[0]) ElemType;

However this change *must* be clearly documented in the changelog, and the requirement should be part of the documentation somewhere.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9547


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|regression                  |normal


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9547



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-19 20:50:43 PST ---
(In reply to comment #0)
> However this change *must* be clearly documented in the changelog, and the requirement should be part of the documentation somewhere.

In addition to that we should change the error message, and perhaps even consider warning the user of a change. E.g. the current error:

> Error: argument string[][0u] to typeof is not an expression

It could be:

Error: Cannot index into a type 'T[0u]', perhaps you meant 'T.init[0]' ?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9547



--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2013-02-19 21:02:53 PST ---
(In reply to comment #0)
> This worked in 2.061, and broke LuaD in 2.062. The workaround (or rather the
> new valid code) is:
> 
> alias typeof(T.init[0]) ElemType;

This is bug fix for issue 6408. `T[0]` should be always analyzed as "zero length static array of T", but it was *accidentally* treated as T.init[0].

> However this change *must* be clearly documented in the changelog, and the requirement should be part of the documentation somewhere.

I can agree that some of proper bug fixes require clear explanation for better migration. We need to pay attention for them in beta phase, and document them.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9547



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-19 21:09:52 PST ---
(In reply to comment #2)
> This is bug fix for issue 6408. `T[0]` should be always analyzed as "zero length static array of T", but it was *accidentally* treated as T.init[0].

Yeah I had a vague memory of this being fixed recently. It's a good change.

> I can agree that some of proper bug fixes require clear explanation for better migration. We need to pay attention for them in beta phase, and document them.

For the upcoming 2.063 release I suggest we keep a special text file (e.g. a local "changes" file in DMD git) where each language change is documented every time such a pull request is merged. This will make sure we never forget to document a language change (it is much harder to do this at the end when there are 150+ bugs fixed).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 17, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9547


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

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


--- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-09-17 16:01:49 PDT ---
Fixed in 2.063, we've had a good changelog for it.

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