Skip to content

Complete semantic layer and lexical scopes #5

Closed

Description

@SizzleUnrlsd

Build the semantic analyses from PyHIR and stop resolving names inside PyIR lowering.

  • semantic/ package with scopes, imports and symbols; move frontend/imports.py there
  • ScopeAnalysis: locals, globals, nonlocal, parameters, closures, function/class/comprehension scopes
  • Python scoping rules: an assignment anywhere in a function makes the name local for the whole function (a read before a later assignment used to resolve to the module import)
  • ImportAnalysis: relative imports resolved from the module name, function-level imports, wildcard imports recorded instead of aborting
  • SymbolAnalysis resolving any name in any scope to a canonical identifier through imports and closures, with builtins as python.builtins.<name>; SymbolId accepts non-python. namespaces such as flask.request.args and django.http.HttpRequest.GET
  • Scope, import and symbol results are immutable values keyed by ScopeId / SymbolId

Reference: docs/architecture.md §4 Semantic Analysis.

Delivery: #4 (layout, scopes), #6 (imports, symbols)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions