Thread overview
[Issue 19545] __traits(compiles, X) false positive, further uses of X succeed but don't link
Jan 03, 2019
John Colvin
Jan 07, 2019
John Colvin
Jan 07, 2019
John Colvin
Dec 20, 2019
John Colvin
January 03, 2019
https://issues.dlang.org/show_bug.cgi?id=19545

John Colvin <john.loughran.colvin@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|phobos                      |dmd

--
January 07, 2019
https://issues.dlang.org/show_bug.cgi?id=19545

--- Comment #1 from John Colvin <john.loughran.colvin@gmail.com> ---
void main()
{
    pragma(msg, __traits(compiles, inputRangeObject(RegexMatch!string.init)));
    inputRangeObject(RegexMatch!string.init);
}

struct RegexMatch(T)
{
}

class InputRangeObject(R)
{
    this(R)
    {
    }

    R front()
    {
    }
}

InputRangeObject!R inputRangeObject(R)(R range)
{
    return new InputRangeObject!R(range);
}

I've tried bisecting to find when in the history this started to go wrong, but it's hard (old dmds don't necessarily build on linux any more due to missing gcc headers).

Here is the output from run.dlang.io, which suggests that there was a problem existing before 2.060, because while there it doesn't mistakenly continue with compilation it still reports `true` when it should say `false`:

Up to      2.060  : Failure with output:
-----
true
onlineapp.d(17): Error: function
onlineapp.InputRangeObject!(RegexMatch!(string)).InputRangeObject.front has no
return statement, but is expected to return a value of type RegexMatch!(string)
-----

           2.061  : Failure with output:
-----
true
onlineapp.o: In function
`_D9onlineapp68__T16inputRangeObjectTS9onlineapp20__T10RegexMatchTAyaZ10RegexMatchZ16inputRangeObjectFS9onlineapp20__T10RegexMatchTAyaZ10RegexMatchZC9onlineapp68__T16InputRangeObjectTS9onlineapp20__T10RegexMatchTAyaZ10RegexMatchZ16InputRangeObject':
/sandbox/onlineapp.d:24: undefined reference to
`_D9onlineapp68__T16InputRangeObjectTS9onlineapp20__T10RegexMatchTAyaZ10RegexMatchZ16InputRangeObject7__ClassZ'
/sandbox/onlineapp.d:24: undefined reference to
`_D9onlineapp68__T16InputRangeObjectTS9onlineapp20__T10RegexMatchTAyaZ10RegexMatchZ16InputRangeObject6__ctorMFS9onlineapp20__T10RegexMatchTAyaZ10RegexMatchZC9onlineapp68__T16InputRangeObjectTS9onlineapp20__T10RegexMatchTAyaZ10RegexMatchZ16InputRangeObject'
collect2: error: ld returned 1 exit status
--- errorlevel 1
-----

--
January 07, 2019
https://issues.dlang.org/show_bug.cgi?id=19545

--- Comment #2 from John Colvin <john.loughran.colvin@gmail.com> ---
class C()
{
    int foo() { }
}

C!() c()()
{
    return new C!()();
}

static assert(!__traits(compiles, c()));

--
December 20, 2019
https://issues.dlang.org/show_bug.cgi?id=19545

--- Comment #3 from John Colvin <john.loughran.colvin@gmail.com> ---
(In reply to John Colvin from comment #2)
> class C()
> {
>     int foo() { }
> }
> 
> C!() c()()
> {
>     return new C!()();
> }
> 
> static assert(!__traits(compiles, c()));

not sure what this was about, maybe I pressed enter too early back then...

The original bug is still there.

--
October 09
https://issues.dlang.org/show_bug.cgi?id=19545

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |industry, wrong-code
                 CC|                            |bugzilla@digitalmars.com

--
October 09
https://issues.dlang.org/show_bug.cgi?id=19545

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |default_357-line@yahoo.de

--- Comment #4 from FeepingCreature <default_357-line@yahoo.de> ---
Probably same bug as https://issues.dlang.org/show_bug.cgi?id=19091 ?

--