Skip to content

Signature refactoring: mechanical slot index rewriting #181

@aallan

Description

@aallan

Summary

When a function signature changes (e.g. adding a parameter of the same type as an existing one), slot reference indices for that type shift throughout the body. The type checker catches all breakage immediately, but fixing it is manual.

A vera refactor command (or extension to vera fmt) could mechanically rewrite all affected references given an old and new signature. The per-type indexing system makes this purely structural — the tool computes the index delta per type and applies it.

Motivation

Criticism of slot references: "Positional indices change with change of structure. Add one argument to a function, and you have to rewrite all of that."

Current mitigations:

  • Per-type indexing limits blast radius (adding @String doesn't shift @Int indices)
  • Type checker catches 100% of breakage (no silent misreferences)
  • But the rewriting itself is still manual

Possible approaches

  1. vera refactor rename-param — given a function name and a signature diff, rewrite all slot references in the body
  2. Extend vera fmt — detect signature/body index mismatches and fix them automatically
  3. LSP integration — signature change triggers automatic reference update

Scope

Ecosystem tooling (C10). The compiler already provides all the information needed (type-indexed binding scopes, deterministic resolution); this is about building the convenience tool on top.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C10C10 — EcosystemenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions