[Issue 19545] __traits(compiles, X) false positive, further uses of X succeed but don't link

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 10 11:39:15 UTC 2022


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

--- Comment #8 from John Colvin <john.loughran.colvin at gmail.com> ---
(In reply to Salih Dincer from comment #6)
> No error, result is true:
> 
> void main()
> {
>   pragma(msg, __traits(compiles, inputRangeObject(RegexMatch!string.init))); 
>   inputRangeObject(RegexMatch!string.init);
> }
> //import std.range, std.regex;/*
> struct RegexMatch(T){}
> 
> class InputRangeObject(R){
>     this(R){}
>     R front(){ return R.init; }
> }
> 
> InputRangeObject!R inputRangeObject(R)(R range) {
>     return new InputRangeObject!R(range);
> }//*/

Yes, if the code is correct then there is no problem. But the code in my
example is not correct and despite that, the traits compiles gives true and
then in more recent compilers the code does compile but then can’t link.

--


More information about the Digitalmars-d-bugs mailing list