Skip to content

defk-rt2.11: the rest of the typing stays twice (ADR-0008 extended); drop Elixir mode's dead ctx write - #67

Merged
DanielLuning merged 1 commit into
mainfrom
defk-rt2.11/typing-stays-twice
Oct 20, 2026
Merged

DanielLuning merged 1 commit into
mainfrom
defk-rt2.11/typing-stays-twice

Conversation

@DanielLuning

Copy link
Copy Markdown
Owner

What changed

The spike defk-rt2.11 asked whether the compiler can hand Elixir mode its node types, so that Elixir mode only emits. The owner decided to close it and keep the typing twice. This PR records that decision and removes a dead write.

  • ADR-0008: a dated extension, "the rest of the typing also stays twice". It records:

    • the measured seam;
    • the decision and its two reasons;
    • a "How to revisit" note.

    The status line names the extension.

  • The dead write: Defk.ElixirMode.definitions/3 set the compiler ctx's :file "so err! reads it". Nothing on Elixir mode's path reads the ctx: a rejection there raises a plain ArgumentError (raise_form!/4), and none of the helpers it calls touches the ctx. The write and the unused file argument are gone, so the function is now definitions/2. Its body uses an implicit try.

  • Arity references: updated in the caller (lib/defk.ex), test/compiler_ctx_test.exs, the compiler map and the inventory row of ADR-0006. No file under test/stability/ or test/contracts/ names the function.

Results

The spike, measured on every test and example module with a throwaway probe (lower_expr/2 against expr/2, through mix dump_c; the full numbers are in the ticket comment):

  • The key: a unique id stamped into each node's meta after the desugar step keys a node. Line and column cannot serve: about 58,000 typings of macro-built kernels have no column. The stamp left the C of all 108 modules byte-identical.
  • Agreement: 57,877 of 58,361 keyed Elixir-mode typings (99.2%) equal the compiler's own type.
  • The rest, four special cases:
    • 71: [u8] against bitstring naming.
    • 35: typed twice by the compiler (the u64 retries, the in guard of case).
    • 92: float trees, which never pass through lower_expr.
    • 286: helpers, which the compiler only inlines.
  • Why not: the u64 accumulator inference decides results (3 - 5 raises as u64, gives -2 as i64), so sharing it removes the agreement tests' check of that decision. Without it, about 20 lines remain to gain.

How it was checked

  • mix ci on the laptop (macOS) passed: 2300 tests, Credo found no issues, Dialyzer reported 0 errors.

  • Touches a promised surface? No: definitions is @doc false and hidden (ADR-0006). No CHANGELOG.md entry.

  • Touches test/stability/? No.

…drop Elixir mode's dead ctx write

The spike found the seam (a node id stamped after desugar keys 99.2% of
Elixir mode's typings to the compiler's, C unchanged) but not the case
for it: the u64 accumulator inference decides results, so sharing it
retires the oracle's check, and the rest gains about 20 lines. ADR-0008
records this and how to revisit it. ElixirMode.definitions/3 set the
compiler ctx's file, which nothing on its path reads: it is
definitions/2 now.
DanielLuning pushed a commit that referenced this pull request Oct 20, 2026
… removal (definitions/2). Closes after the merge."
@DanielLuning
DanielLuning merged commit b90ed0f into main Oct 20, 2026
2 checks passed
@DanielLuning
DanielLuning deleted the defk-rt2.11/typing-stays-twice branch October 20, 2026 09:03
DanielLuning pushed a commit that referenced this pull request Oct 20, 2026
… on 2026-10-20). rt2.11 closed as a finding: the rest of the typing stays twice (ADR-0008 extended)."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant