www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10334] New: ddoc should prefer simple syntax for template instantiations with one parameter

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

           Summary: ddoc should prefer simple syntax for template
                    instantiations with one parameter
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: ddoc
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



07:46:42 PDT ---
-----
/** */
template templ(T...)
    if (someConstraint!T)
{
}
-----

This currently emits:

 template templ(T...) if (someConstraint!(T))
But for readability purposes it can be:
 template templ(T...) if (someConstraint!T)
-- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 11 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10334




09:07:31 PDT ---
This is a little bit complicated to implement. I have to take into account at
least the following (where left is the input, right is the output), and these
are also used for .di header generation so they must have valid D syntax:

Templ!() -> Templ!()
Templ!(T) -> Templ!T
Templ!T -> Templ!T
Templ!([1]) -> Templ!([1])  // cannot be Templ![1]
Templ!(Templ2!(T)) -> Templ!(Templ2(T)  // cannot be Templ!Templ2!T

That last case is what I'm struggling with. How do I figure out whether an
Object from 'tiargs' is a template instance in DMDFE?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 11 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10334


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/dmd/pull/2173

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 13 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10334




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/920c3c1344d4f74ca04eb29cd2a7cc59169745d6
Supplemental fix for issue 10334

https://github.com/D-Programming-Language/phobos/commit/b39768890581b423a85186aa4c6ded1337051641


Supplemental fix for issue 10334

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 17 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10334




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/920c3c1344d4f74ca04eb29cd2a7cc59169745d6
Supplemental fix for issue 10334

https://github.com/D-Programming-Language/phobos/commit/b39768890581b423a85186aa4c6ded1337051641


Supplemental fix for issue 10334


Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/905c4dd8e6a0377c518cce443f63a237df39ac7d
fix Issue 10334 - ddoc should prefer simple syntax for template instantiations
with one parameter

https://github.com/D-Programming-Language/dmd/commit/26022fb60e542f387257359d347cb9f3a21653ca


Issue 10334 - ddoc should prefer simple syntax for template instantiations with
one parameter

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 17 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10334


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



This code:


template isBar(T) {
    enum isBar = false;
}
template Foo(T) if (isBar!T) {
}
void main() {
    alias F = Foo!int;
}


Gives (before this patch):

temp.d(7): Error: template instance Foo!(int) does not match template
declaration Foo(T) if (isBar!(T))

isn't it better to use that ddoc logic to generate a simpler error message
similar to:

temp.d(7): Error: template instance Foo!(int) does not match template
declaration Foo(T) if (isBar!T)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 17 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10334




18:14:55 PDT ---

 isn't it better to use that ddoc logic to generate a simpler error message
 similar to:
Yes, although the pull request didn't touch any ddoc code, it specifically targeted the internal Template "stringification" functions which are used by both ddoc and diagnostics. I thought all diagnostics would be affected, but some slipped out (they weren't directly tested in the autotester, only ddoc output was tested). I think the diagnostics can be improved. Could you file a separate bug for it? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 17 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10334






 I think the diagnostics can be improved. Could you file a separate bug for it?
I have compiled the compiler with this last change, and indeed there is no need to file a bug, the error message now is: temp.d(7): Error: template instance Foo!int does not match template declaration Foo(T) if (isBar!T) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 17 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10334




18:56:13 PDT ---


 
 I think the diagnostics can be improved. Could you file a separate bug for it?
I have compiled the compiler with this last change, and indeed there is no need to file a bug, the error message now is: temp.d(7): Error: template instance Foo!int does not match template declaration Foo(T) if (isBar!T)
Ah yes, my bad. I used the wrong version when testing it now. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 17 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10334


Kenji Hara <k.hara.pg gmail.com> changed:

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


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