Thread overview
[Issue 14346] is-expression dependent on instantiation order
Mar 26, 2015
Ketmar Dark
Mar 26, 2015
Ketmar Dark
Apr 25, 2015
ag0aep6g@gmail.com
Apr 25, 2015
ag0aep6g@gmail.com
Feb 14, 2022
RazvanN
March 26, 2015
https://issues.dlang.org/show_bug.cgi?id=14346

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ketmar@ketmar.no-ip.org

--- Comment #1 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
seems that there is some bug with template merging. change your template declarations to this:

template isConvertibleToInstanceOf(alias From, alias To, usize dummy=__LINE__)
template isConvertibleToInstanceOf(From, alias To, usize dummy=__LINE__)

and you will never see pragma output from second `static if`.

--
March 26, 2015
https://issues.dlang.org/show_bug.cgi?id=14346

--- Comment #2 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
ah. `usize` is simply an alias for `size_t`. sorry.

--
April 25, 2015
https://issues.dlang.org/show_bug.cgi?id=14346

ag0aep6g@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g@gmail.com

--- Comment #3 from ag0aep6g@gmail.com ---
Reduced further:

----
template typeOf(alias From)
{
    alias typeOf = typeof(From);
}

string val;
int embedded;

void main()
{
    foreach(UDA; Tuple!val)
    {
        pragma(msg, typeOf!UDA); /* prints "string", ok */
    }
    foreach(UDA; Tuple!embedded)
    {
        /* THE RESULT OF THIS DEPENDS ON THE LINE ABOVE: */
        pragma(msg, typeOf!UDA); /* prints "string", should print "int" */
    }
}

alias Tuple(stuff ...) = stuff;
----

This is very similar to issue 14501.

--
April 25, 2015
https://issues.dlang.org/show_bug.cgi?id=14346

ag0aep6g@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code

--
February 14, 2022
https://issues.dlang.org/show_bug.cgi?id=14346

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |razvan.nitu1305@gmail.com
         Resolution|---                         |FIXED

--- Comment #4 from RazvanN <razvan.nitu1305@gmail.com> ---
(In reply to ag0aep6g from comment #3)
> Reduced further:
> 
> ----
> template typeOf(alias From)
> {
>     alias typeOf = typeof(From);
> }
> 
> string val;
> int embedded;
> 
> void main()
> {
>     foreach(UDA; Tuple!val)
>     {
>         pragma(msg, typeOf!UDA); /* prints "string", ok */
>     }
>     foreach(UDA; Tuple!embedded)
>     {
>         /* THE RESULT OF THIS DEPENDS ON THE LINE ABOVE: */
>         pragma(msg, typeOf!UDA); /* prints "string", should print "int" */
>     }
> }
> 
> alias Tuple(stuff ...) = stuff;
> ----
> 
> This is very similar to issue 14501.

When running the above code the second pragma prints int as expected. It seems that this has been fixed.

--