[Issue 19792] New: Rtypeof expression in parameter list appears to select wrong overload

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 7 14:31:12 UTC 2019


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

          Issue ID: 19792
           Summary: Rtypeof expression in parameter list appears to select
                    wrong overload
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: asumface at gmail.com

The following code fails since 2.085.x:

struct Node // dummy struct
{ int box; }
Node node;

auto box() @property
{
    return node.box;
}
auto anythingButBox(typeof(box) arg) @property
{
    return node.box = arg;
}
auto box(typeof(box()) arg) @property
{
    return node.box = arg;
}
auto box(typeof(box) arg) @property
{
    return node.box = arg;
}

The definition
auto box(typeof(box()) arg) @property
fails with:
Error: forward reference to template box

The definition
auto box(typeof(box) arg) @property
fails with:
Error: forward reference to template box
Error: forward reference to template box
(That's right, twice!)

If the definition of
auto box() @property
is moved below all others, previous versions of dmd segfault, I therefore
conclude that this is related to issue #19717.

auto box(typeof(box()) arg) @property
then fails with:
Error: forward reference to template box
Error: none of the overloads of box are callable using argument types (),
candidates are:
    onlineapp.box(typeof(box()) arg)
    onlineapp.box(typeof(box) arg)
    onlineapp.box()
(the overload error is contradicting itself here!)

auto box(typeof(box) arg) @property
with:
Error: forward reference to template box
Error: circular typeof definition

--


More information about the Digitalmars-d-bugs mailing list