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.63k stars 1.47k forks source link

fix subtype match of generic object types #24430

Closed metagn closed 1 week ago

metagn commented 1 week ago

split from #24425

Matching tyGenericBody performs a match on the last child of the generic body, in this case the uninstantied tyObject type. If the object contains no generic fields, this ends up being the same type as all instantiated ones, but if it does, a new type is created. This fails the sameObjectTypes check that subtype matching for object types uses. To fix this, also consider that the pattern type could be the generic uninstantiated object type of the matched type in subtype matching.

github-actions[bot] commented 1 week ago

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

Hint: mm: orc; opt: speed; options: -d:release 177442 lines; 8.840s; 652.32MiB peakmem