Jump to page: 1 2
Thread overview
[Issue 19091] __traits(compiles) and error in templated structs leads to missing symbol
Jul 17, 2018
FeepingCreature
Jul 02, 2020
FeepingCreature
Jul 02, 2020
FeepingCreature
Jul 02, 2020
FeepingCreature
Jul 02, 2020
Mario Kroeplin
Sep 10, 2020
FeepingCreature
Sep 10, 2020
FeepingCreature
Sep 14, 2020
FeepingCreature
Sep 14, 2020
FeepingCreature
Sep 14, 2020
FeepingCreature
Sep 14, 2020
FeepingCreature
Dec 01, 2020
Dlang Bot
Dec 05, 2020
Walter Bright
Mar 24, 2022
FeepingCreature
Mar 24, 2022
FeepingCreature
Mar 24, 2022
FeepingCreature
Dec 17, 2022
Iain Buclaw
July 17, 2018
https://issues.dlang.org/show_bug.cgi?id=19091

--- Comment #1 from FeepingCreature <default_357-line@yahoo.de> ---
Note that __traits(compiles) evaluates to true?!

--
July 02, 2020
https://issues.dlang.org/show_bug.cgi?id=19091

--- Comment #2 from FeepingCreature <default_357-line@yahoo.de> ---
Found a new version of this bug:

```
void early()() { Struct!() var; }

struct Struct() { void fun() { error; } }

void main() {
    void helper()() { early; }

    static assert(!__traits(compiles, helper()));
    helper();
}
```

--
July 02, 2020
https://issues.dlang.org/show_bug.cgi?id=19091

--- Comment #3 from FeepingCreature <default_357-line@yahoo.de> ---
Correction, sorry; didn't pay attention and accidentally pasted a working version. This one properly linker errors:

```
void early()() { auto var = Struct!()(0); }

struct Struct() { this(int) { } void fun() { error; } }

void main() {
    void helper()() { early!(); }

    static assert(!__traits(compiles, helper()));
    helper();
}
```

--
July 02, 2020
https://issues.dlang.org/show_bug.cgi?id=19091

--- Comment #4 from FeepingCreature <default_357-line@yahoo.de> ---
A different way of provoking the same effect:

```
struct Struct() {
    static void missing() { } // this will be missing from the linker
    void fun() { error; } // will provoke an error if attempted to compile
}

void helper1()() { Struct!().missing; }

void helper2()() { helper1(); }

void main() {
    static assert(!__traits(compiles, helper2()));
    helper1();
}
```

--
July 02, 2020
https://issues.dlang.org/show_bug.cgi?id=19091

Mario Kroeplin <kroeplin.d@googlemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |industry
                 CC|                            |kroeplin.d@googlemail.com

--
September 10, 2020
https://issues.dlang.org/show_bug.cgi?id=19091

--- Comment #5 from FeepingCreature <default_357-line@yahoo.de> ---
https://issues.dlang.org/show_bug.cgi?id=21235 might be the same bug? I don't know.

--
September 10, 2020
https://issues.dlang.org/show_bug.cgi?id=19091

FeepingCreature <default_357-line@yahoo.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|enhancement                 |normal

--
September 14, 2020
https://issues.dlang.org/show_bug.cgi?id=19091

--- Comment #6 from FeepingCreature <default_357-line@yahoo.de> ---
Update: version that makes it clearer what happens:

```
struct Template {
    void opEquals(U, this TA)(U) {
        pragma(msg, "Template.opEquals!(" ~ U.stringof ~ ", " ~ TA.stringof ~
")");
        foo();
    }
}

void foo()() {
    static assert(false); // foo() fails xeq semantic3 while gagged
    bar!();
}

// this is the symbol that sticks around and references foo().
// Despite foo() erroring, bar() is not errored and emits normally.
void bar()() {
    pragma(msg, "bar()");
    foo();
}

void main() { }
```

--
September 14, 2020
https://issues.dlang.org/show_bug.cgi?id=19091

--- Comment #7 from FeepingCreature <default_357-line@yahoo.de> ---
Unified with what I'm learning from the testcase from 21235:

```
// gag the foo error
static assert(!__traits(compiles, foo()));

void foo()() {
    static assert(false);
    bar!();
}

// foo() is not errored while bar compiles? because circular
void bar()() { foo(); }

// no error
void main() { bar(); }
```

I don't think we'll get it smaller than this.

--
September 14, 2020
https://issues.dlang.org/show_bug.cgi?id=19091

--- Comment #8 from FeepingCreature <default_357-line@yahoo.de> ---
*** Issue 21235 has been marked as a duplicate of this issue. ***

--
« First   ‹ Prev
1 2