Skip to content

javascript func_start: bare call-site identifiers with no capturing group fall back to whole-match-text naming, producing phantom functions #1452

Closed

Description

@squid-protocol

Summary

tests/tools/tree_sitter_accuracy_audit.py --lang javascript measures func_start precision at
73.5%. One confirmed, reproducible false-positive mechanism: a bare call-site identifier (an
imported function being CALLED, not defined) is matched by some alternative in the func_start
regex with NO capturing group of its own, causing detector.py's fallback naming logic
(raw_name = match.group(match.lastindex) if match.lastindex else match.group(0), around lines
1809/2263/2383) to fall back to the ENTIRE match text (since match.lastindex is None when no
group participated) and extract a phantom function name from it.

Repro

language-crucible/data/javascript/jquery/css.js:314:

					swap( elem, cssShow, function() {

swap here is an imported function (import { swap } from "./css/var/swap.js";, line 12) being
CALLED with an inline anonymous callback -- not a definition of anything named swap. Confirmed
via direct func_start.finditer(): this line produces a match with m.groups() entirely
(None, None, ...) (no named group captured) and m.group(0) equal to '\t\t\t\t\tswap' (just
leading whitespace + the bare word swap, no parens/args/brace included in the match at all).
Since no group participated, match.lastindex is None, and the pipeline's fallback logic uses
the whole match text as the raw name, which _extract_name then reduces to swap -- reported as
a phantom function. Same shape recurs across the corpus for other imported-then-called names
(attemptEarlyBailoutIfNoScheduledUpdate, bailoutOnAlreadyFinishedWork, beginWork in
react/ReactFiberBeginWork.js, addHelper in threejs/Editor.js).

Suggested fix shape

This looks like an alternative within javascript's func_start regex that's intended to detect
some OTHER construct (likely an anonymous-function/callback-adjacent shape, or a keyword-based
alternative without its own name-capture group) but is also incidentally matching a bare
call-site identifier with nothing to actually distinguish "this is a real anchor" from "this is
just an identifier token sitting at a matched position." Needs direct tracing of javascript's
func_start regex (gitgalaxy/standards/language_standards.py, "javascript" entry) to find
which alternative produces a match with zero capturing groups for input like swap( elem, ..., function() { -- once identified, either give that alternative its own proper name-capturing
group (so the fallback-to-whole-match-text path isn't needed) or tighten its lookahead/lookbehind
so it can't fire on a plain call-site identifier. Verify against
tests/extraction/languages/test_javascript.py and re-run
python tests/tools/tree_sitter_accuracy_audit.py --lang javascript --regenerate to confirm
extra_functions drops without found_functions regressing.

Scope note

This only affects func_start/args/class_start name-extraction accuracy (the extraction-
gauntlet pillar from epic #813), not GitGalaxy's risk-scoring rules, which are unaffected. Note
the tool's own documented caveat that some javascript "extra" samples (e.g. getIteratorFn in
react/ReactSymbols.js) are a SEPARATE, already-understood ground-truth gap (Flow-typed syntax
the plain javascript tree-sitter grammar can't parse) -- not the same mechanism as this issue,
don't conflate the two when triaging the full "extra" sample list.

Activity

  1. added
    bug
    testing
    core-engine
    threat: false-positive
    on Aug 13, 2026
  2. added this to the v2.4.8 milestone on Aug 16, 2026
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: mediumtestingthreat: false-positive

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions