Skip to content

calls_out (Go): throw( is a call, and (*T)(x) conversions are calls - #3722

Merged
squid-protocol merged 1 commit into
mainfrom
claude/go-calls-out-3645
Sep 26, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
claude/go-calls-out-3645

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Fixes #3645 (part of #3641). The engine missed two kinds of Go call.

1. throw was ignored in every language. _CALLS_OUT_GLOBAL_IGNORE listed throw because it is a keyword in C++, Java and JS. But Go's runtime throw("…") is a real function (runtime/panic.go), and so are MATLAB's and Haskell's, so every one of those calls was lost. Contract C2 says keywords are per language, so throw moves into _calls_out_ignore of each calls_out language where it is a keyword: apex, cpp, csharp, dart, groovy, java, javascript, kotlin, livecode, objective-c (@throw), php, scala, solidity, swift and typescript. PowerShell already listed it. C/C++ macro bodies in wrapper_extractor keep ignoring it.

2. Go conversions to a parenthesized type. (*gcBgMarkWorkerNode)(nodep) and (*uintptr)(unsafe.Pointer(p)) are conversions, and a conversion is a call (C3). But \b(name)\s*\( can't see past the ). Go now has its own pattern, CALLS_OUT_GO, registered in QUALIFIED_CALLS_OUT_PATTERNS:

  • It takes (*T)(, (**T)(, (*[N]T)( and (*pkg.T)(. The callee is T, and pkg becomes its qualifier, the way tree-sitter names it.
  • The plain name( form no longer consumes its (. Before this, return (*m)(p) swallowed the conversion's opening paren, since return ( looked like a call.
  • A ( right after a name, ) or ] is not treated as a conversion. So h(next)(w, r), a call of the function h returns, records only h and never next.
  • ReDoS: every quantifier is bounded, and the callee lookahead only starts at the beginning of a word. My first version rescanned from inside a word and took quadratic time on a 100k-character name. That payload is now in the ReDoS tests.

docs/calls_out_rule_contract.md C2 and C3 record both decisions.

Type of change

  • Bug fix
  • New feature / language support
  • Parsing or engine logic (gitgalaxy/core/detector.py, language_standards.py, prism.py, or a per-language rule)
  • Docs, tooling, or CI only
  • Other (describe above)

CI checklist

  • python tests/tools/audit_check.py passes (bundles the ruff/mypy/dead-key baseline-gated audits + ruff format --check)
  • python -m pytest tests/ passes
  • Touches parsing/engine logic? python tests/tools/crucible_check.py passes. Both fixtures were re-blessed; see below.
  • Touches parsing/engine logic? tree_sitter_accuracy_audit.py --all --ci: not run locally. It scores functions, classes and args, which this PR doesn't touch; CI runs it.
  • Changes the CLI's output JSON schema? No.

Measurements

call_graph_accuracy.py (Level 1, against tree-sitter), on language-crucible v1.5.0:

go before after
recall 96.4% 99.6%
missed calls 239 29
precision 99.9% 99.9%
false positives 5 5

No other language moved. The baseline is regenerated.

Of the 29 Go misses left, 26 are defer func(){…}() / go func(){…}(). For those, the tree-sitter side names an identifier inside the anonymous function as the callee: a quirk of the reference tool, not an engine miss.

Golden masters, scoped diff: 7 differences, identical in both modes, all from Go.

  • go/core/proc.go gains one downstream file edge from the calls it now sees (conversions to types defined in other files, and throw). That moves its:
    • direct downstream (2 → 3);
    • popularity rank (2 → 3);
    • composition fit (1.327 → 1.385).
  • server.go's composition fit moves (0.836 → 0.856).
  • The network-wide assortativity and average path length move in the fourth decimal.
  • The PageRank values in undocumented_critical_path shift.

keyword-rosetta: rosetta_audit.py finds 51 languages, 0 regressions. No non-keyword language in the corpus writes throw(.

Differential Scan target

language-crucible go/core (golang runtime: proc.go, mgc.go, value.go, syscall_linux.go).

Verification

$ pytest tests/extraction/languages/ -k "calls_out or go"                -- 481 passed
$ pytest tests/                                                           -- 11537 passed, 333 skipped
$ python tests/tools/audit_check.py                                       -- all clear
$ python tests/tools/call_graph_accuracy.py --ci --buckets 3              -- OK (go 96.4% -> 99.6% recall)
$ python tests/tools/crucible_check.py --mode both --update --yes         -- both updated; 7 Go-only diffs reviewed
$ python tests/tools/rosetta_audit.py --corpus ../keyword-rosetta         -- 51 languages, 0 regressions

New tests: tests/extraction/languages/test_calls_out_go_3645.py, which covers:

  • Go's throw as a call, and throw staying a keyword in each of the 16 keyword languages;
  • the conversion shapes, and decoys where a closing paren must not start one;
  • the qualifier;
  • ReDoS payloads.

test_calls_out_generics_3644.py no longer expects Go to use the plain C-style pattern.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GCpfMCUMpco98QGbsuv2sr


Generated by Claude Code

…3645)

- `throw` leaves the global keyword ignore set: go's runtime `throw("...")`,
  matlab's and haskell's are functions. It moves into `_calls_out_ignore` of
  each calls_out language where it is a keyword (apex, cpp, csharp, dart,
  groovy, java, javascript, kotlin, livecode, objective-c, php, scala,
  solidity, swift, typescript; powershell already had it). C macro bodies in
  wrapper_extractor keep ignoring it.
- go gets CALLS_OUT_GO: a conversion to a parenthesized type, `(*T)(x)`,
  `(**g)(p)`, `(*[2]Timeval)(p)`, `(*unsafe.Pointer)(p)`, is a call to the type
  (qualifier `unsafe`). The plain `name(` form no longer consumes its `(`, so
  `return (*m)(p)` still sees the conversion. `h(next)(w)` records only `h`.

call_graph_accuracy (go): recall 96.4% -> 99.6% (FN 239 -> 29), precision
99.9% unchanged; no other language moved. Goldens: proc.go gains one
downstream edge (popularity, blast radius, composition fit), plus the
network-wide averages and PageRank ripple.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GCpfMCUMpco98QGbsuv2sr
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 73c177c into main Sep 26, 2026
36 checks passed
@squid-protocol
squid-protocol deleted the claude/go-calls-out-3645 branch September 26, 2026 11:28
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.

calls_out (go): throw( dropped by the global keyword ignore; (*T)(x) conversions missed

2 participants