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

fixes #23628; Compiler crash for nested generic type instantiations with static[int] #24426

Closed metagn closed 1 week ago

metagn commented 1 week ago

Original PR is #23630 by @Nimaoth, could not personally commit the refactor to that PR so had to open this one branched off from it.

Symbols of generic parameters with static constraints can lose their tyGenericParam type in favor of the static type. This trips up the compiler, which expects only tyGenericParam, when attempting to instantiate the parameters of a tyGenericInvocation to look it up in the cache. To fix this, also consider the uninstantiated static case.

I don't know why only generic parameters are instantiated here and not any type before looking at the cache, will have to look into it after.

Edit: This breaks tmatrix4 but the original doesn't