Repository navigation
Description
Found while implementing #2558 (Batch B.3 of #2669). Distinct mechanism from #2558, so filed separately — the same discipline #2558 itself followed when it split off from #2530.
The defect
func_start branch 1 (the {1,18}-prefix-token branch) has a negative lookahead that keeps statement keywords from being captured as the function name, but nothing stops them being consumed as a prefix token. The bare-identifier prefix alternative is unguarded:
r"(?:…|[a-zA-Z_][a-zA-Z0-9_<>\[\]?,\.]*)[ \t\n]+){1,18}"So return, throw, new, and friends satisfy the prefix, and the next identifier becomes the "function name":
| real code | misread as a declaration named |
|---|---|
throw new IllegalArgumentException(msg) |
IllegalArgumentException |
return acceptOrReject(x) |
acceptOrReject |
specInfo.addInterceptor new I(…) |
I |
addresses new LinkedList(…) |
LinkedList |
The last two are the paren-less-call shape from #2558 with a new expression as the sole argument, rather than an _(…) lookup.
Scale
Measured over the full language-crucible groovy corpus (305 files), branch 1 only, post-#2558:
83 of 968 branch-1 matches (8.6%) are this false positive. 59 distinct shapes:
x6 'throw new IllegalArgumentException' x3 'throw new RuntimeException'
x5 'return acceptOrReject' x3 'throw new UnsupportedOperationException'
x5 'return isAnnotatedWithIncubating' x2 'new Object' / 'new Gson'
x4 'throw new Exception' x2 'throw new TestAbortedException'
That is substantially larger than the 3-match idiom #2558 fixed, and it matters more than a signal count: func_start feeds the function slicer, so every one of these invents a phantom function and drags functions_found, avg_func_loc, avg_func_complexity, func_complexity_gini and structural_mass with it.
Fix shape
Guard the bare-identifier prefix alternative the same way the name capture is already guarded — a statement keyword is not a type or a modifier:
r"(?:…|(?!(?:new|return|throw|assert|yield)[ \t\n])[a-zA-Z_][a-zA-Z0-9_<>\[\]?,\.]*)[ \t\n]+){1,18}"Validated on the same corpus: branch 1 968 → 885 (−83), and every one of the 83 is a genuine non-declaration — I checked all 59 distinct shapes, and the nine that do not begin with a statement keyword (specInfo.addInterceptor new I, addresses new LinkedList, the six featureInfo.*Interceptor new I variants) are the paren-less-call-with-new-argument shape, i.e. also false positives. No real declaration is lost.
The keyword list is deliberately narrow — only statement keywords that can legally precede an expression. class, interface, enum, trait are not included: they are already excluded as names, and they genuinely do precede declarations.
Corpus impact
None. rosetta groovy branch 1 stays at its planted 13 → 13, so this needs no rebless and can ship in the same zero-movement wave as #2660 / #2673 / #2544 / #2558.
Tests
tests/extraction/languages/test_groovy_strict.py: throw new X(…), return foo(…), obj.method new X(…) are not func_starts; def foo(x) { }, String bar(int y) { }, static void baz() { }, abstract Map<String, Integer> calculateTotals(List<Item> items) still are; and #2530's named-argument-map shape and #2558's raw _("x") stay excluded.
Activity
squid-protocol commentedon Sep 2, 2026
Correcting my own figures in the issue body: the measurement above was taken over only the 181
*.groovyfiles while quoting a 305-file count from a different scan..gradlefiles are groovy too — this rule's own exclusion list is full of Gradle DSL tokens (implementation,classpath,mavenCentral,allprojects, …) — so they belong in the sample.Re-measured over the full groovy-language set (306 files:
.groovy+.gradle+Jenkinsfile), using the livefunc_startrule with and without the guard:func_start1121 → 1028 (−93, 8.3% of all matches).The conclusion is unchanged and if anything stronger. All 93 removals are genuine non-declarations: 83 lead with a guarded statement keyword (
throw new IllegalArgumentException,return acceptOrReject, …) and the other 10 are the paren-less-call-with-new-argument shape —specInfo.addInterceptor new I, the sixfeatureInfo.*Interceptor new Ivariants,addresses new LinkedList,storeFile new File, and one multi-linethrow new Error. Zero matches added; no real declaration lost. rosetta groovyfunc_startstays at its planted 13.chore(crucible): re-bless golden masters for the B.3 wave-1 regex batch
fix(core-engine): Rosetta batch 3 wave 1 — five registry-regex fixes …
squid-protocol commentedon Sep 3, 2026
Closing: verified fixed on main.
groovy'sfunc_startno longer reads a guarded statement keyword as a declaration —throw new IllegalArgumentException(msg)does not match. Landed in #2677 (Batch B.3 wave 1 of #2669), which did not carry a closing keyword.