Skip to content

Type AST: foundation enum + parser + printer + round-trip tests #161

@frendsick

Description

@frendsick

Parent PRD

#140

What to build

Define the Type sum type and the boundary helpers needed to migrate string-typed slots one at a time. No call sites change yet.

enum Type {
    Builtin(BuiltinType)             # int, bool, str, char, ptr, cstr, void, ...
    Generic(str, List[Type])         # base name + parameter types
    Function(List[Type], List[Type]) # parameters, returns
    TypeVar(str)                     # generic type parameter
}

Add parse_type str -> Type (must accept everything the current string-based code stores) and Type.format -> str (must produce strings the existing parser/printer accepts). Cover nested generics, function types, type variables. See parent PRD's "Proposed solution".

Acceptance criteria

  • Type enum defined in compiler/common.casa with the four variants above
  • parse_type and Type.format implemented
  • Round-trip tests in tests/test_compiler.sh (or compiler unit tests) covering: builtins, nested generics (List[Map[str int]]), function types, type variables
  • No production call site changed yet — helpers exist alongside current string code
  • tests/test_examples.sh and tests/test_compiler.sh pass

Blocked by

None - can start immediately.

User stories addressed

Foundation for all of #140. Migration step 1 in parent PRD.

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