Skip to content

zig func_start misses extern/export calling-convention prefix and @"..."-quoted identifier names #1419

Closed

Description

@squid-protocol

Summary

tests/tools/tree_sitter_accuracy_audit.py --lang zig measures func_start recall at only 73.9%
(1828/2473 real functions found), while precision is already 100% (0 extra_functions) -- so
this is a pure, safe recall gap with zero risk of new false positives, the same low-risk shape as
#1266's earlier zig/scala/matlab broadening. Two confirmed, independent causes, both in
gitgalaxy/standards/language_standards.py's "zig" -> rules["func_start"]:

1. extern "<callconv>" fn is not recognized. Zig's calling-convention string literal
between extern/export and fn isn't in the regex's accepted prefix shapes.

Repro, language-crucible/data/zig/zig/main.zig:5662:

extern "c" fn ZigClang_main(argc: c_int, argv: [*:null]?[*:0]u8) c_int;

Missed. Same shape accounts for the ZigClangIsLLVMUsingSeparateLibcxx,
ZigClang_main, ZigLlvmAr_main misses in that file, and the Win32-FFI misses in
zls/mach/win32.zig (AdjustWindowRectExForDpi, BringWindowToTop, CoCreateInstance, ...).

2. Zig's @"..."-quoted identifier syntax is not recognized as a function name. Zig allows
any string as an identifier (needed for names that collide with reserved words, or for FFI symbol
names with characters an ordinary identifier can't contain) via @"..." syntax. The name-capture
group only accepts plain [a-zA-Z_]\w*.

Repro, language-crucible/data/zig/zig/Compilation.zig:349:

    pub fn @"resume"(t: *Timer) void {

Missed (real name is the reserved word resume, spelled @"resume"). Same shape accounts for
the bun/napi.zig misses, which are @"..."-quoted C++-mangled V8 symbol names
(@"??0EscapableHandleScope@v8@@QEAA@PEAVIsolate@1@@Z" etc.) -- an FFI-heavy real-world pattern,
not a synthetic edge case.

Suggested fix shape

  • Add extern/export followed by an optional string-literal calling-convention token
    ("c", "C", etc.) as an accepted prefix shape alongside the existing bare extern fn/
    export fn handling.
  • Extend the name-capture alternation to also accept @"(?:[^"\\]|\\.)*" (a quoted identifier,
    same escaping rules as a normal Zig string literal) alongside the existing bare-identifier and
    operator-shaped alternatives.

Both are additive/broadening changes to the name-capture and prefix-detection shapes -- zero
existing false positives on this corpus to preserve, so risk is low, same as #1266. Verify against
tests/extraction/languages/test_zig.py and re-run
python tests/tools/tree_sitter_accuracy_audit.py --lang zig --regenerate to confirm
found_functions rises without extra_functions moving off 0.

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. The
args_exact_match mismatches also visible in the audit output (e.g.
bun/MimallocArena.zig::gc real=1 got=2) are a separate, not-yet-investigated concern -- out of
scope for this issue, which is about the two recall gaps above only.

Activity

  1. added
    bug
    testing
    core-engine
    threat: false-negative
    priority: low
    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: lowtestingthreat: false-negative

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions