Skip to content

Fix TSP inferred returns for definition-site computed types#4045

Open
WilliamK112 wants to merge 1 commit into
facebook:mainfrom
WilliamK112:codex/tsp-definition-return-4042
Open

Fix TSP inferred returns for definition-site computed types#4045
WilliamK112 wants to merge 1 commit into
facebook:mainfrom
WilliamK112:codex/tsp-definition-return-4042

Conversation

@WilliamK112

Copy link
Copy Markdown

Fixes #4042.

Summary

  • Treat exact TSP range requests for function and method definition names like identifier lookups instead of expression traces.
  • Preserve declaration-based computed types so unannotated functions, methods, and property getters keep their inferred returnType at definition sites.
  • Add TSP interaction coverage for definition-site ranges plus a same-name reference range under untyped-def-behavior = check-and-infer-return-type.

Validation

  • cargo +stable-x86_64-pc-windows-gnu test -p pyrefly test_get_computed_type_definition_site_uses_inferred_return_type -- --nocapture
  • cargo +stable-x86_64-pc-windows-gnu test -p pyrefly get_type_queries
  • cargo +stable-x86_64-pc-windows-gnu test -p pyrefly tsp_interaction
  • cargo +stable-x86_64-pc-windows-gnu fmt --all --check
  • git diff --check
  • cargo +stable-x86_64-pc-windows-gnu test -p pyrefly test_shape_dsl_reports_multiple_errors -- --nocapture

I also attempted the full cargo +stable-x86_64-pc-windows-gnu test -p pyrefly suite. It reached 6188 passed, 1 failed; the only failure was the unrelated test::shape_dsl::test_shape_dsl_reports_multiple_errors internal watchdog timeout (Error: Test took too long (> 20s)) during the full parallel run. The same test passed when rerun directly, as shown above.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TSP: inferred return type dropped at definition-site requests (unannotated functions / methods / @property getters render -> Unknown)

2 participants