Thread overview
[Issue 20686] ICE with __traits and templated member function referenced in non-templated member function
Mar 21, 2020
Simen Kjaeraas
Mar 21, 2020
Boris Carvajal
Mar 21, 2020
Boris Carvajal
[Issue 20686] failed static assert when using a combination of __traits in an unfinished type
May 04, 2020
Basile-z
May 04, 2020
Basile-z
[Issue 20686] failed static assert using a combination of __traits and unfinished type
May 04, 2020
Basile-z
May 04, 2020
Basile-z
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=20686

Simen Kjaeraas <simen.kjaras@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice
                 CC|                            |simen.kjaras@gmail.com
            Summary|type of tuple is lost?      |ICE with __traits and
                   |                            |templated member function
                   |                            |referenced in non-templated
                   |                            |member function

--- Comment #1 from Simen Kjaeraas <simen.kjaras@gmail.com> ---
By prodding the code a bit, I was able to get a compiler crash. I believe the core issue is the same. Here's the simplified code:

struct S() {
    void fun() {
        gun("");
    }
    void gun(T)(T) {
        alias buggy = bug;
    }
}

alias X = S!();

void main() {
    X().gun(0);
}

alias bug =  __traits(getMember, X, "fun");

I've not been able to reduce it beyond this.

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=20686

moonlightsentinel@disroot.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |moonlightsentinel@disroot.o
                   |                            |rg

--- Comment #2 from moonlightsentinel@disroot.org ---
According to run.dlang.io it's a regression from 2.087.0:

2.084.1 to 2.086.1: Failure with output: onlineapp.d(16): Error:
`__traits(getMember, S!(), "fun")` does not give a valid type
Since      2.087.1: Segfault and no output

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=20686

--- Comment #3 from moonlightsentinel@disroot.org ---
Bisection blames this commit:

commit caf888bd949a119c2136be6ee7011eedbf3f5f0b
Author: Basile Burg <basile.b@gmx.com>
Date:   Sat Jul 6 13:37:10 2019 +0200

fix issue 19708 - Can't use __traits(getAttributes, ...)[...] as a type

Introduced in https://github.com/dlang/dmd/pull/10144

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=20686

Boris Carvajal <boris2.9@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |boris2.9@gmail.com

--- Comment #4 from Boris Carvajal <boris2.9@gmail.com> ---
Simen Kjaeraas: that is a different bug which I just solved a few hours ago, it can show with nested alias declarations with the trait get member or similar. Gonna file a new issue.

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=20686

--- Comment #5 from Boris Carvajal <boris2.9@gmail.com> ---
related issue 20692

--
May 04, 2020
https://issues.dlang.org/show_bug.cgi?id=20686

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp@gmx.com
            Summary|ICE with __traits and       |failed static assert when
                   |templated member function   |using a combination of
                   |referenced in non-templated |__traits in an unfinished
                   |member function             |type

--
May 04, 2020
https://issues.dlang.org/show_bug.cgi?id=20686

--- Comment #6 from Basile-z <b2.temp@gmx.com> ---
reduced to make reasoning on the problem easier

---
alias AliasSeq(TList...) = TList;

struct El(T) {
    void f2()       { f(null); }
    void f(T2)(T2)  { static assert(getSymbols!(El!T, "f2").length); }
}

alias X = El!char;

void main() {
    X().f('a');
}

template getSymbols(alias symbol, names...) {
    static if (names.length == 0)
        alias getSymbols = AliasSeq!();
    else
        alias getSymbols =
          AliasSeq!(__traits(getMember, symbol, names[0]),
                             getSymbols!(symbol, names[1 .. $]));
}
---

observations:

1. if you move the X definition in main() then that compiles ;
2. if you use this insted of El!T in El.f() then this compiles ;
3. if you use f('0') in El.f2() then this compiles,
   because this matches to the instance called in main() ;

The 3rd point seems meaningful.

--
May 04, 2020
https://issues.dlang.org/show_bug.cgi?id=20686

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|failed static assert when   |failed static assert using
                   |using a combination of      |a combination of __traits
                   |__traits in an unfinished   |and unfinished type
                   |type                        |

--
May 04, 2020
https://issues.dlang.org/show_bug.cgi?id=20686

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice                         |

--