I am starting to lose track of all bug reports linked to generics and static early symbol resolution.
Context
Quoting @Araq
The pre-instantiation lookup is required to implement the proper "open vs closed symbol lookup" rules.
http://nim-lang.org/docs/manual.html#generics-symbol-lookup-in-generics
It's a tough issue, maybe we need to weaken the prepass if a 'this' parameter is used.
Impact
Solution
Most advanced discussion is in #8603
Quoting @zah
Er, it's a bug and a rather simple one. The generic pre-pass in semgnrc.nim have to examine the when condition expressions in the same way it examines all other expressions.
The fix I imagine is that you should just call semGenericStmt on the when condition expression (n.sons[0])
I'll have to look at some specific examples. Inside the compiler, we keep track of which generic symbols are in "unresolved" state and we need to add guards in the code detecting such symbols in many places. I suspect something similar is going on here as well.
I am starting to lose track of all bug reports linked to generics and static early symbol resolution.
Context
Quoting @Araq
Impact
strformatdoesn't work properly inside generics #7632:strformatdoesn't work properly inside generics and templateswhenshould check the code at the same depth likeifwhenbranch is missing field types #9899: Documentation withwhenbranch is missing field typesitemsiterator #11167: Template with for loop invoked from generic procedure defined in another module cant finditemsiteratorSolution
Most advanced discussion is in #8603
Quoting @zah