[Issue 19196] DMD thinks storage size for pointer or dynamic array isn't always known

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 27 05:58:22 UTC 2018


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

| <dhasenan at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dhasenan at gmail.com

--- Comment #2 from | <dhasenan at gmail.com> ---
Reduced testcase that doesn't rely on phobos:

---
struct Foo(T)
{
    alias F = typeof(T.tupleof);
}

struct B
{
        // Error: struct `test.A` no size because of forward reference
        Foo!(B)[] arr;
}
---

In typesem.d:3495, we call `mt.sym.size(e.loc);`. We use it as a shortcut to
run semantic analysis on the type before getting the type tuple. This results
in a bad error message, but it's straightforward to improve that error message.

Obviously, some stuff won't fly, so we can't glibly leave everything to a later
semantic step. The fix required to make this work fully is to run minimal
semantic analysis during tupleof, lazily finish that semantic analysis, and
only error out then.

That would catch the obvious problem of:

---
struct Foo
{
  static if (!hasElaborateDestructor!B) ~this() {}
}
struct B
{
  Foo foo;
}
---

But would let the original example compile.

Unfortunately, that level of change is beyond me at the moment.

--


More information about the Digitalmars-d-bugs mailing list