[Issue 18287] [Reg 2.078.1] several std.math functions no longer work with alias this

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 2 21:02:35 UTC 2021


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

--- Comment #4 from John Colvin <john.loughran.colvin at gmail.com> ---
(In reply to hsteoh from comment #1)
> Has signbit() ever worked with alias this types?  I tried commenting out the
> new sig constraint of signbit(), but this code still fails to compile on git
> master:
> 
> --------
> struct Proxy {
>     double f;
>     alias f this;
> }
> auto p = Proxy(1.61803);
> auto sign = signbit(p);
> --------
> 
> The compiler says:
> ---------
> std/math.d(267): Error: cannot implicitly convert expression 4.50360e+15 of
> type double to Proxy
> std/math.d(5762): Error: template instance std.math.floatTraits!(Proxy)
> error instantiating
> std/math.d(5806):        instantiated from here: signbit!(Proxy)
> --------
> 
> This is caused by signbit() attempting to instantiate floatTraits with
> Proxy, but floatTraits does not take alias this into account.
> 
> (Not that it *shouldn't* work with alias this, but just that it doesn't seem
> to have worked before. Or perhaps that only broke after floatTraits was
> introduced?)

It did work before dmd 2.066.0

struct Proxy {
    double f;
    alias f this;
}

void main(){
    import std.math;
    auto p = Proxy(1.61803);
    auto sign = signbit(p);
}

Up to      2.065.0: Success and no output

https://run.dlang.io/is/WHDPrI

--


More information about the Digitalmars-d-bugs mailing list