www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21351] New: When struct A is imported inside struct B,


          Issue ID: 21351
           Summary: When struct A is imported inside struct B, with(B)
                    gets passed to A() constructor.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

Consider these three files:

--- a.d
struct A { int value; }

--- b.d
struct B { import a : A; }

--- test.d
void main() { with (B()) A(0); }

DMD will say:

test.d(5): Error: cannot implicitly convert expression __withSym of type B* to

Despite B() not being necessary or allowed for A().

Oct 30 2020