Hasty Briefsbeta

Bilingual

Quadratic Micropass Type Inference

2 days ago
  • #type inference
  • #compiler design
  • #error messages
  • Introduces quadratic micropass type inference to prioritize type unifications based on user assumptions, improving error messages.
  • Describes the limitation of inside-out inference in languages like Go and the pitfalls of type variable unification in complex scenarios.
  • Explains the ordered passes of the algorithm: known_applications, known_assignments, known_return_types, known_same_as_unifications, known_record_fields, resolve_records, less_known_functions, default_numbers, default_unknown_to_unit_or_lift.
  • Uses examples to demonstrate how the algorithm resolves misleading type errors, such as inferring 'int' over 'string' in a return statement.
  • Provides a benchmark showing performance with an Intel i7 processor: 100 iterations in 7.79ms and 50,000 iterations in 2.78s, noting its viability for projects with many small functions.