[Issue 19520] New: TypeExp is TypeExp: cannot interpret at compile time / is not an expression

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 27 21:54:16 UTC 2018


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

          Issue ID: 19520
           Summary: TypeExp is TypeExp: cannot interpret at compile time /
                    is not an expression
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: ibuclaw at gdcproject.org

https://github.com/dlang/dmd/pull/8945 introduced a funny little test.

---
struct Foo { alias MyInt = int; }
assert(attribs[0] is Foo);  // TypeExp is TypeExp.
---

This errors in gdc's codegen, because we build the back-end expression before
checking the type, but it succeeds with dmd because it checks the type and
doesn't evaluate the expression as it's empty.

We can easily break dmd though...

---
struct Empty { }
struct WithSym { int i; }

void test()
{
    // error: cannot interpret Empty at compile time
    static assert(Empty is Empty);
    // error: cannot interpret WithSym at compile time
    static assert(WithSym is WithSym);
    // This compiles !!!
    assert(Empty is Empty);
    // error: type WithSym is not an expression
    assert(WithSym is WithSym);
}
---

It's quite clear that either all should succeed, or the third test should fail.

I don't think its outside the scope of CTFE to evaluate `assert(type is type)`
as either true or false, so that should be addressed.

--


More information about the Digitalmars-d-bugs mailing list