Skip to content

Function extraction gaps found by the new node maps: one-line definitions, Erlang spec with a record, Nim operator names #9200

Backlog

Description

@squid-protocol

What is wrong

Mapping crystal, erlang, nim, julia, r and fsharp in the tree-sitter accuracy audit (PR linked below) measured their function extraction against tree-sitter for the first time. Besides two grammar limits, it exposed four engine gaps. Each repro below was run in isolation with galaxyscope ... --db-only and the rows read from function_data.

1. Definitions with the body on the same line are not extracted (Julia short form, Nim, F#)

function foo(x)
    x + 1
end
square(x) = x * x          # not in function_data (also `index(df) = ...`, `nrow(df) = ...`)
proc multi(x: int): int =
  result = x + 1
proc oneLiner(x: int): int = x * 2    # not extracted
let multi (x: int) =
    x + 1
let oneLiner (x: int) = x * 2          # not extracted

In all three the multi-line definitions are found and the one-liners are not, although the func_start rules (julia.py "a short-form f(x) = ...", nim.py, fsharp.py) match them. Effect on the new baselines: julia function recall 43.0% (422 of 981; short-form definitions are about half of the reference), fsharp 45.8% (120 of 262), nim 82.3%.

2. Erlang: a function directly after a -spec that contains a record type is dropped

-module(t).
-record(state, {}).
start() -> ok.

-spec init([]) -> {ok, #state{}}.
init([]) ->
	ok.

foo(X) -> X.

function_data has start and foo, not init. Without the #state{} in the spec, or without the spec, init is found. gen_server callbacks (init, handle_call, handle_cast, handle_info, code_change, terminate) are spec'd with #state{} as a rule, which is most of the 53 missed Erlang functions (erlang recall 90.3%, 494 of 547).

3. Nim: a backticked operator proc is extracted but unnamed

proc `+`(a, b: Foo): Foo =
  a

The row is named Unknown_Block (a synthetic name the audit ignores), so $, ==, [], * and friends never match by name. nim.py says a backticked operator "keeps its backticks"; the pipeline does not keep it.

4. Not a bug, a follow-up: named class extraction is off for these languages

detector.py (#1264) names classes only for an allowlisted set of languages; crystal, erlang, nim, julia, r and fsharp are not on it, so their class names come from the generic fallback (Crystal's class HTTP::Client is read as HTTP). The audit now measures classes for crystal and erlang (23 of 54 and 0 of 52 found) and leaves the other four unmapped. Enrolling a language means hardening its class_start, then verifying it with this audit.

Expected

1 and 2 are extraction defects; 3 is a naming defect; each should get a test from the repro above. After each fix, regenerate the language's baseline in the CI-matched environment (tests/tools/tree_sitter_accuracy_audit.py --lang X --regenerate) so the improvement is locked in.

Filed as one issue under the class-sweep rule; found while building the node maps.

Activity

  1. added
    bug
    core-engine
    on Nov 24, 2026
  2. squid-protocol commented on Nov 25, 2026

    @squid-protocol
    OwnerAuthor

    Churn run 9200-20261125T0751Z (host melek) ended without a PR. Filler run denied: fix committed locally on churn/9200-20261125T0751Z (F#/OCaml indentation-stream lifetime pattern); fsharp accuracy baseline regenerate refused (extra_functions 6->7, real 'and' binding the tree-sitter node map misses). Needs owner call: accept the extra or teach the audit's node map 'and' bindings. Filler is terminal; not requeued.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-enginepriority: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions