Skip to content

Conversation

@coord-e
Copy link
Owner

@coord-e coord-e commented Oct 24, 2025

  • Enable to map type params to arbitrary types in TypeBuilder
  • When a poly fn is fully annotated, we check the function definition immediately by substituting the parameter with some type
  • When a poly fn is not annotated, we defer the check until type args are provided when we visit the function's call site

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for polymorphic (generic) functions in Thrust's refinement type system. The implementation introduces a deferred type checking mechanism where polymorphic functions without full annotations are analyzed on-demand when called with specific type arguments.

  • Introduces TypeArgs vs RefinedTypeArgs distinction to separate unrefined type arguments from refined ones
  • Implements deferred type checking with caching for polymorphic function instantiations
  • Adds ParamTypeMapper to allow mapping type parameters during template generation
  • Adds comprehensive test coverage with pass/fail test pairs for various polymorphic scenarios

Reviewed Changes

Copilot reviewed 42 out of 42 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/rty/params.rs Introduces TypeArgs type alias and separate From implementations for TypeArgs and RefinedTypeArgs
src/rty.rs Adds PartialEq, Eq, Hash derives to enable caching, updates signatures to use RefinedTypeArgs
src/refine/template.rs Adds ParamTypeMapper trait and with_param_mapper method to support type parameter substitution during template generation
src/analyze/local_def.rs Moves annotation extraction and expected_ty logic from crate analyzer to local def analyzer
src/analyze/crate_.rs Refactors to use local def analyzer methods, adds logic to defer polymorphic function checking
src/analyze/basic_block.rs Updates to use stored type_builder and def_ty_with_args for generic function calls
src/analyze.rs Introduces DefTy enum with Concrete and Deferred variants, implements on-demand type checking with caching
src/chc.rs Adds PartialEq, Eq, Hash derives to support type caching
tests/ui/pass/*.rs Adds 16 passing test cases covering polymorphic functions with various features
tests/ui/fail/*.rs Adds 16 failing test cases as counterparts to validate error detection

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coord-e coord-e merged commit ad2262c into main Nov 23, 2025
9 checks passed
@coord-e coord-e deleted the params branch November 23, 2025 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants