Thread overview
[Issue 18287] [Reg 2.078.1] several std.math functions no longer work with alias this
[Issue 18287] several std.math functions no longer work with alias this
Mar 02, 2018
Martin Nowak
Dec 17, 2018
Eduard Staniloiu
Dec 12, 2019
berni44
Nov 01, 2021
Ate Eskola
Nov 02, 2021
John Colvin
January 23, 2018
https://issues.dlang.org/show_bug.cgi?id=18287

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx

--
January 23, 2018
https://issues.dlang.org/show_bug.cgi?id=18287

--- Comment #1 from hsteoh@quickfur.ath.cx ---
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?)

--
March 02, 2018
https://issues.dlang.org/show_bug.cgi?id=18287

Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code@dawg.eu
            Summary|several std.math functions  |[Reg 2.078.1] several
                   |no longer work with alias   |std.math functions no
                   |this                        |longer work with alias this

--
December 17, 2018
https://issues.dlang.org/show_bug.cgi?id=18287

Eduard Staniloiu <edi33416@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |edi33416@gmail.com

--- Comment #2 from Eduard Staniloiu <edi33416@gmail.com> ---
So, what is the general consent here?
Should this work with `alias this`, or should we close as `WONTFIX`?

IMHO, this is more likely a compiler bug, as the template constraint should also be checked on `alias this`, if one is present.

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

berni44 <bugzilla@d-ecke.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@d-ecke.de
         Resolution|---                         |FIXED

--
November 01, 2021
https://issues.dlang.org/show_bug.cgi?id=18287

Ate Eskola <Ajieskola@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |Ajieskola@gmail.com
         Resolution|FIXED                       |---

--- Comment #3 from Ate Eskola <Ajieskola@gmail.com> ---
Someone marked this issue as resolved, but provided no reasoning. This won't do - I'm reopening until there's a verifiable fix.

--
November 02, 2021
https://issues.dlang.org/show_bug.cgi?id=18287

--- Comment #4 from John Colvin <john.loughran.colvin@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

--