Skip to content

feat(codegen): preserve Python overload input and return relationships #336

Closed

Description

@bbopen

The Python extractor records overloads, but TypeScript conversion drops them.

Reproduced on 6b84614 with advanced_types.get_value: IR contains two overloads, while generation emits getValue(key: string | number): Promise<string | number>.

See IROverload and mapFunc. This differs from shipped generic-parameter support in #209 and historical mapper work in #146.

Acceptance criteria:

  • Preserve supported overloads through IR conversion and generated .ts and .d.ts output.
  • String and integer calls infer their corresponding declared return types in compile-only tests.
  • Invalid calls fail typechecking instead of matching an overly broad fallback.
  • Runtime argument binding and return validation agree with supported overload behavior.
  • Unsupported or ambiguous cases produce explicit diagnostics.
  • Preserve positional-only, keyword-only, default-argument, and generic regression coverage.

Coordinate with #335 and implement after its architecture decision. This issue does not approve a wholesale generator rewrite.

Architectural approach:

Preserve overloads in the complete callable contract from #335. Use #344 to verify the selected input-to-return relationship before broader overload implementation. Coordinate through #345.

Activity

  1. added this to the Backlog milestone on Sep 11, 2026
  2. self-assigned this
    on Sep 11, 2026
  3. bbopen commented on Sep 20, 2026

    @bbopen
    OwnerAuthor

    Generated implementations and declarations retain overloads without a broad fallback. Tests cover correlated input/output types, invalid-call type errors, runtime binding, selected wrong-return rejection, and ambiguity diagnostics. Actual Python extraction tests now cover positional-only parameters with defaults and keyword-only parameters; existing tests cover generics. Python 3.11 and 3.12 run the overload extraction assertions, while 3.10 retains its documented fallback.

    Evidence: test/fixtures/python/positional_overloads.py, test/ir_contract.test.ts, test/integration.test.ts, and test/isolated_consumer.conformance.ts.

    Verified release evidence:

    The architecture decision records the accepted scope and prototype limits.

    Closing with the implemented and verified 0.11 release outcome.

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

Metadata

Metadata

Assignees

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions