nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.61k stars 1.47k forks source link

remove structural equality check for objects and distinct types #24448

Closed metagn closed 4 days ago

metagn commented 5 days ago

follows up #24425, fixes #18861, fixes #22445

Since #24425 generic object and distinct types now accurately link back to their generic instantiations. To work around this issue previously, type matching checked if generic objects/distinct types were structurally equal, which caused false positives with types that didn't use generic parameters in their structures. This structural check is now removed, in cases where generic objects/distinct types require a nontrivial equality check, the generic parameters of the typeInst fields are checked for equality instead.

The check is copied from tyGenericInst, but the check in tyGenericInst is not always sufficient as this type can be skipped or unreachable in the case of ref objects.

github-actions[bot] commented 4 days ago

Thanks for your hard work on this PR! The lines below are statistics of the Nim compiler built from a2031ec6cfe9475fb38ebc204ebcf8c2b6d02dce

Hint: mm: orc; opt: speed; options: -d:release 177825 lines; 8.643s; 653.555MiB peakmem