Repository navigation
csharp: func_start linear on adjacent [...] and <...> runs (Part of #3320) - #4999
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| the 60s worker fuse (it used to exceed it, so the file shipped with 0 functions).""" | ||
| import time | ||
|
|
||
| func_start = LANGUAGE_DEFINITIONS["csharp"]["rules"]["func_start"] |
Contributor
Owner
Author
|
Tick review: parity delta accepted. The 1,829 lost matches are phantom derivations from the redundant |
Owner
Author
|
No description provided. |
squid-protocol
marked this pull request as ready for review
October 12, 2026 17:29
squid-protocol
enabled auto-merge (squash)
October 12, 2026 17:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #3320
What
C#
func_startparsed any[...]run three ways on failure (the attribute shield, single[/]chars in the return-type token class, and the\[[^\]]{0,80}\]token), so k adjacent brackets cost 3^k. Brackets now have one owner each, with no atomic groups or possessive quantifiers (py3.10-safe):\[(?:[^\[\]]|\[(?:[^\[\]]|\[[^\[\]]{0,40}\]){0,80}\]){0,250}\](two nested levels; every char class excludes[/]);[is removed from the return-type token's char class. The\[...\]suffix stays (int[],T[,]). A token may start with[only as an empty rank specifier (byte [] M());<: it was a char and also the start of the<...>group (.C0<int>.C1<int>..., 260 levels = 2^260, three runtime files timed out on BOTH old and new bracket-only). The<char alternative is now(?!<group>)<, so it applies only where the group can't match (3+ nesting).Evidence
UserDefinedCompoundAssignmentOperatorsTests.cs60s timeout / 0 functions -> 1264 matches in 0.1s. runtimeNestedGeneric{Classes,Structs,TypesMix}.cs: 60s timeout -> 0.0s.data.hdd/+ language-crucible): total old regex time 421s -> 53s, slowest file 0.29s.crucible_check.py --update --yesunder golden-lock: no drift on both legs;scope_check.py --expect csharp --mode both: 0 differences.pr_gates --fast5/5 pass;--ratchets7 pass, 0 fail, 0 skipped.Parity delta (not zero; for the tick to accept or reject)
Match set of the old regex vs new (name at line, 47,305 files, 898,844 old matches): crucible csharp 0; estates 1829 lost (0.2%), 33 gained, in 263 roslyn/runtime/PowerShell files (roslyn 1606, runtime 210, PowerShell 14 by the first pass). Each lost match is a phantom the old redundant
[derivation produced, not a declaration:[line ([\n Edit(SemanticEditKind.Update, ...),->Edit,Row,SemanticEdit,DocumentResults,Diagnostic;[|int x = ...;\n Console.WriteLine(x);|]).item[await GetOffsetAsync(GetOffset(ref item))] += 1;->GetOffsetAsync,Program<T>.F[await Get0()]++).[([InlineData("[A] void local() { }")],// [A] void M1() { }, ILinstance valuetype [mscorlib]...add_E (, VBProperty [Select](...),[|F|]-style test markup).d < F()comparison ->F,public void Goo($$){}inside a raw-string test source;Update [static void F()markup).Spot checks found no genuine declaration lost. An earlier intermediate version did lose
byte [] M()/T [] method<S>()(space before[], Mono corpus style); fixed and pinned by tests. Gained (33): real declarations the old redundant derivations missed, e.g.[return: NativeInteger(new[] { false, true })] static UIntPtr[] M2()(nested bracket in an attribute),static void F(object? x, object?[] y),void S.F(scoped R r).Zero delta would mean keeping the phantoms, which are the extra derivations.
Tests
tests/extraction/languages/test_csharp_strict.py(time-bounded): stacked[InlineData(1, 2)]x400;[GetA][Get0][G1][operator]1Truex400 (+ one-line and empty-rank variants); a syntheticUserDefinedCompoundAssignmentOperatorsTests.csshape (4000 expected-output lines) extracts both methods in < 5s; the 260-level generic chain; 17-case bracket-ownership parity table.Class sweep (same mechanism in other languages)
Timed all 53
func_startregexes (n=12 vs 24; 18 shapes:[a][b]...,[[a]],@A @B,@A(1) @B(2),@Foolines, Java nested@A(@B(...)), Kotlin@get:C @field:[D E], Swift@objc @available(...), Rust#[derive], indexers, nested generics). None grows super-linearly or exceeds 0.5s; the harness flags old C# on 5 shapes. So no sibling in Java, Kotlin, Swift, C++, etc.Cross-repo: none.
🤖 Generated with Claude Code