[Issue 14093] [REG2.065] __traits(compiles, cast(Object)(tuple)) is true even if it doesn't compile.

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat May 30 06:53:03 PDT 2015


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

--- Comment #7 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to Igor Stepanov from comment #6)
> This issue is not fully solved.
> There is simpler example:
> -----------------------------------------
> struct FooBar
> {
>     int a;
>     int b;
> }
> 
> void test14093()
> {
>     FooBar foo;
>     auto obj = cast(Object)foo; //e2ir: cannot cast foo of type FooBar to
> type object.Object
> }
> -----------------------------------------

Will be fixed by:
https://github.com/D-Programming-Language/dmd/pull/4691

> Moreover, I think, this issue is solved incorrectly: alias this mechanism
> should reject `cast(Object)(point._tupleAliasThis_)` variant and continue
> process the root casting "cast(Object)point" excluding alias this.
> And result error message should be 
> "Error: cannot cast expression point of type Tuple!(int, "x", int, "y") to
> object.Object".
> We are interested in subtyping (alias this, or inheritance) only when it can
> done its work (casting, .member ...).

It's rather diagnostic issue. I opened a new minor issue 14632.

--


More information about the Digitalmars-d-bugs mailing list