https://d.puremagic.com/issues/show_bug.cgi?id=11858

           Summary: Comparison of unconnected classes using `is` must be
                    disallowed
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from Denis Shelomovskij <[email protected]> 2014-01-02 
19:49:31 MSK ---
Comparison of unconnected classes using `is` is definitely a mistake. If one
want to do such raw things for some reason, he has to cast to e.g. `Object` or
`void*` first. Currently such construction is allowed even in `@safe` code.

This code should compile:
---
class A { }
class B { }

void main()
{
    A a;
    B b;
    static assert(!__traits(compiles, a is b)); // fails
}
---

As a result of the issue it's to easy to make a mistake like `a.prop1 is b`
instead of `a.prop1.owner is b`. Also a refactoring of class hierarchy by
segregating subclasses becomes a nightmare as you get no errors from type
system in situations when you e.g. forget to change `find` predicate.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to