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 standalone explicit generic procs with unresolved arguments #24404

Closed metagn closed 3 weeks ago

metagn commented 3 weeks ago

fixes issue described in https://forum.nim-lang.org/t/12579

In #24065 explicit generic parameter matching was made to fail matches on arguments with unresolved types in generic contexts (the sigmatch diff, following #24010), similar to what is done for regular calls since #22029. However unlike regular calls, a failed match in a generic context for a standalone explicit generic instantiation did not convert the expression into one with tyFromExpr type, which means it would error immediately given any unresolved parameter. This is now done to fix the issue.

For explicit generic instantiations on single non-overloaded symbols, a successful match is still instantiated. For multiple overloads (i.e. symchoice), if any of the overloads fail the match, the entire expression is considered untyped and any instantiations are not used, so as to not void overloads that would match later. This means even symchoices without unresolved arguments aren't instantiated, which may be too restrictive, but it could also be too lenient and we might need to make symchoice instantiations always untyped. The behavior for symchoice is not sound anyway given it causes #9997 so this is something to consider for a redesign.

Diff follows #24276.

github-actions[bot] commented 3 weeks ago

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

Hint: mm: orc; opt: speed; options: -d:release 176961 lines; 8.650s; 653.582MiB peakmem