Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Python TSG: Error when typed function parameters with splat operator #408

@ghost

Description

The following input causes the Python TSG to fail.

Input

def f(**kwargs: Any):
  pass

CST

(module [0, 0] - [3, 0]
  (function_definition [0, 0] - [1, 11]
    name: (identifier [0, 4] - [0, 5])
    parameters: (parameters [0, 5] - [0, 20]
      (typed_parameter [0, 6] - [0, 19]
        (dictionary_splat_pattern [0, 6] - [0, 14]
          (identifier [0, 8] - [0, 14]))
        type: (type [0, 16] - [0, 19]
          (identifier [0, 16] - [0, 19]))))
    body: (block [1, 7] - [1, 11]
      (pass_statement [1, 7] - [1, 11]))))

Error

ExecutionError(
  InContext(
    Statement(
    [StatementContext {
      statement: "edge @name.def -> @param.param_name at (853, 3)",
      statement_location: Location { row: 852, column: 2 },
      stanza_location: Location { row: 842, column: 0 },
      source_location: Location { row: 1630, column: 59 },
      node_kind: "typed_parameter" }
    ]),
    InContext(
      Other("Evaluating edge source"),
      UndefinedScopedVariable("[syntax node dictionary_splat_pattern].def"))))

Suggested mitigation

[
  (parameter/typed_parameter
--    . (_) @name) @param
++    . (identifier) @name) @param
  (parameter/list_splat_pattern
--    (_) @name) @param
++    (identifier) @name) @param
  (parameter/dictionary_splat_pattern
--    (_) @name) @param
++    (identifier) @name) @param
] {
  attr (@name.def) node_definition = @name
  attr (@param.param_name) push_node = @name
  edge @name.def -> @param.param_name
  edge @name.def -> @param.param_index
  edge @param.input -> @name.def
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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