Skip to content

[Meta] Generics/Static early symbol resolution #8677

@mratsim

Description

@mratsim

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions