Skip to content

New semantic analyzer: only create each SymbolNode once #6300

Closed

Description

@JukkaL

Currently we can create a symbol node multiple times (once per iteration), which is risky since we don't want to risk having different references to a particular name pointing to different nodes. For example, class-based TypedDict definitions may create multiple TypeInfo objects per definition.

I think that for most things we can treat the definition as complete once we've successfully created a symbol table node, and further iterations would skip the definition, as there's nothing more to do.

Normal class definitions should not have this problem, but we should verify that these work as expected:

  • Var nodes
  • TypedDict (as discussed above)
  • Named tuples
  • Type variables
  • Type aliases
  • NewTypes
  • Enums

Activity

  1. ilevkivskyi commented on Feb 7, 2019

    @ilevkivskyi
    Member

    @JukkaL the problem with AnyStr I told you about was caused by this. I fixed this for type vars, but we still need to check other node kinds in this list.

  2. self-assigned this
    on Mar 14, 2019
  3. ilevkivskyi commented on Mar 15, 2019

    @ilevkivskyi
    Member

    Just a note to self that we need to fix TypeVar redefinition by preserving a link to defining assignment (I will make a PR).

  4. JukkaL commented on Jun 12, 2019

    @JukkaL
    CollaboratorAuthor

    Lowering priority since I believe that we've addresses most issues (but not necessarily all).

  5. JukkaL commented on Jun 12, 2019

    @JukkaL
    CollaboratorAuthor

    We currently allow submodules to be redefined as various different things (see #6828) which breaks these assumptions. It looks like we need another approach for dealing with storing submodules. The current approach is problematic in other ways as well.

  6. ilevkivskyi commented on Jun 26, 2019

    @ilevkivskyi
    Member

    I think we have fixed all the cases I am aware. We still do some patching/updating of the existing nodes (replace placeholder types in base classes, alias targets, and variable upper bounds), but we don't re-add symbol table nodes. If we will discover more, we can open dedicated issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions