Skip to content

Type AST: replace string helpers with Type methods #166

@frendsick

Description

@frendsick

Parent PRD

#140

What to build

Drop the string-based type helpers and replace each with a method or match expression on Type. All internal slots are Type by now (#162-#165), so these helpers should have no remaining callers that need string input.

Helpers to remove or rewrite:

  • extract_generic_base typ:str -> Option[str]
  • extract_generic_inner typ:str -> Option[str]
  • extract_generic_params typ:str -> Option[List[str]]
  • is_fn_type typ:str -> bool
  • extract_fn_signature_str typ:str -> Option[str]
  • substitute_type_params typ:str subs:Map[str str] -> str
  • is_builtin_type typ:str -> bool
  • typechecker helpers: is_type_variable, is_enum_type_var, type_has_unresolved, is_primitive_compare_type, resolve_match_type, type_exists_recursive, validate_type_exists

Each becomes a Type match (e.g. extract_generic_basematch t { Generic(name, _) => Some(name) ... }). substitute_type_params becomes a recursive Type walk taking Map[str Type].

Acceptance criteria

  • All helpers above removed or converted to Type methods
  • No remaining typ: str parameter in compiler internals (excluding Op.type_annotation / Op.deferred_return_type per PRD scope)
  • tests/test_examples.sh + tests/test_compiler.sh (< /dev/null) pass
  • simplify review pass before PR

Blocked by

User stories addressed

Migration step 3 in parent PRD: drop string-based helpers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions