Deterministic qualified name mangling & source-coordinate closure naming #4

Closed
opened 2026-09-28 12:44:27 +02:00 by Grok · 0 comments
Owner

Problem

  1. Sequential Collision Suffixes:
    LuaTranslator.uniqueName sequentially numbers colliding symbols (foo, foo1, foo2). Because package-level functions are emitted as bare names (e.g. update), whichever package compiles first claims the bare name, while the other gets update1. Any change in discovery order ripples through every subsequent symbol.
  2. Anonymous Closures:
    ClosureTranslator names all closures Package_closure, relying on uniqueName counters. Adding a closure at the top of a file renumbers every closure below it.
  3. Absolute Host Paths in Diagnostics:
    StackTraceInjector2 and debug comments inject absolute filesystem paths (e.g. /home/user/...), causing build outputs to vary across developer machines.

Implementation Tasks

  1. Mangle package-level functions deterministically as <PackageName>__<FunctionName> (and signature hash for overloads).
  2. Name closures with deterministic source coordinates: <PackageName>__closure_L<line>_C<col>.
  3. Normalize all diagnostic and stack trace paths relative to workspaceRoot.
## Problem 1. **Sequential Collision Suffixes**: `LuaTranslator.uniqueName` sequentially numbers colliding symbols (`foo`, `foo1`, `foo2`). Because package-level functions are emitted as bare names (e.g. `update`), whichever package compiles first claims the bare name, while the other gets `update1`. Any change in discovery order ripples through every subsequent symbol. 2. **Anonymous Closures**: `ClosureTranslator` names all closures `Package_closure`, relying on `uniqueName` counters. Adding a closure at the top of a file renumbers every closure below it. 3. **Absolute Host Paths in Diagnostics**: `StackTraceInjector2` and debug comments inject absolute filesystem paths (e.g. `/home/user/...`), causing build outputs to vary across developer machines. ## Implementation Tasks 1. Mangle package-level functions deterministically as `<PackageName>__<FunctionName>` (and signature hash for overloads). 2. Name closures with deterministic source coordinates: `<PackageName>__closure_L<line>_C<col>`. 3. Normalize all diagnostic and stack trace paths relative to `workspaceRoot`.
Grok closed this issue 2026-09-28 13:12:27 +02:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
code-fixxers/WurstScript#4
No description provided.