Skip to content

Commit 07bb106

Browse files
committed
P-037 A2.2-4R2: F-PARAMS-ELEMENT repaired; an expanded params element is classified with its element conversion
A2.2-4's completeness oracle found (formal note §10.6.10, F-PARAMS-ELEMENT, §10.1 case 1) that an expanded params argument was classified from its bare syntax. Roslyn attaches no argument operation to such an argument — the ParamArray argument carries the call's own syntax — so the span-containment match found nothing and the fallback classified `model.GetOperation` of the element alone: under parentheses or the null-forgiving `!` there is no operation of the element's own and the handle was lost (the call not relevant, no fact); a struct handle boxed into `params object[]` or a handle passed through op_Implicit into `params Box[]` classified as the unconverted local and yielded an opaque-and-relevant slot although nothing of the handle reaches the callee. Pinned RED on the pairwise cases whose binding is params and whose value-flow shape is parens, bang, boxing or user_implicit. The repair, in EmitCall.ValueOf: when no argument operation is attached to the argument's span, look the element up in the ParamArray argument's array initializer (the IArrayCreationOperation element whose syntax the argument contains) before falling back to the bare expression. The element carries its own conversion, so the existing walker decides it with no new rule: `(r)` and `r!` yield the local reference (a handle; the params slot stays opaque and the call relevant), a boxed element yields a boxing conversion and a user-converted element a user-defined one (not a handle, no fact). The collapsed form, an array passed whole, matched by span before and still does. Nothing else in the binding or the walker moves. Measured on this tree: the 52 census shapes read byte-identical; the probe's oracle reading is unchanged (RED 1, F-MEMBER); the affected pairwise cases read green by the generic design (the pinning block leaves the generator); every other pinned RED stays as pinned (F-MEMBER, F-CONDITIONAL-RECEIVER, F-VOCAB); the inertness control and the local rehearsal against the T before-takes are unchanged on both engines. The ledger moves F-PARAMS-ELEMENT to `closed`; spec/OwnIR.md §5.2 states the element rule; §10.6.9 and §10.6.11 record the landing. Same instrument, no new T/R. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QfeUtLRm6KFRWcTGQZxQQb
1 parent 8e693ba commit 07bb106

6 files changed

Lines changed: 60 additions & 44 deletions

File tree

‎corpus/p037-hostile/expected.json‎

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@
466466
"binding": "params",
467467
"carrier": "orphan_local"
468468
},
469-
"carrier": "guarded_functions",
469+
"carrier": "none",
470470
"occurrences": [
471471
{
472472
"symbol": "r",
@@ -481,10 +481,7 @@
481481
"explanation": "storage_assignment"
482482
}
483483
],
484-
"red": {
485-
"fact_without_relevant_occurrence": 1
486-
},
487-
"finding": "F-PARAMS-ELEMENT"
484+
"red": {}
488485
},
489486
"pw-ctor-cast-checked-pos-record-local": {
490487
"member": "H_pw_ctor_cast_checked_pos_record_local.M",
@@ -1353,10 +1350,7 @@
13531350
"explanation": "receiver_not_summary_parameter"
13541351
}
13551352
],
1356-
"red": {
1357-
"occurrence_not_captured": 1
1358-
},
1359-
"finding": "F-PARAMS-ELEMENT"
1353+
"red": {}
13601354
},
13611355
"pw-del-switch-default-unmodelled-local": {
13621356
"member": "H_pw_del_switch_default_unmodelled_local.M",
@@ -1914,10 +1908,7 @@
19141908
"ordinal": 1
19151909
}
19161910
],
1917-
"red": {
1918-
"fact_without_relevant_occurrence": 1
1919-
},
1920-
"finding": "F-PARAMS-ELEMENT"
1911+
"red": {}
19211912
},
19221913
"pw-inv-array-pos-record-local": {
19231914
"member": "H_pw_inv_array_pos_record_local.M",
@@ -2057,7 +2048,7 @@
20572048
"binding": "params",
20582049
"carrier": "orphan_local"
20592050
},
2060-
"carrier": "none",
2051+
"carrier": "guarded_functions",
20612052
"occurrences": [
20622053
{
20632054
"symbol": "r",
@@ -2072,10 +2063,7 @@
20722063
"explanation": "storage_assignment"
20732064
}
20742065
],
2075-
"red": {
2076-
"occurrence_not_captured": 1
2077-
},
2078-
"finding": "F-PARAMS-ELEMENT"
2066+
"red": {}
20792067
},
20802068
"pw-inv-bang-pos-unmodelled-param": {
20812069
"member": "H_pw_inv_bang_pos_unmodelled_param.M",

‎corpus/p037-relevance/oracle_findings.json‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@
99
"status": "open: a census finding; carrying these members in the orphan carrier is a production change to be classified on its own",
1010
"red": "occurrence_not_captured"
1111
},
12-
"F-PARAMS-ELEMENT": {
13-
"class": "case 1",
14-
"title": "an expanded params element is classified from its bare syntax",
15-
"evidence": "For an expanded params argument the argument operation carries the call's own syntax, so the span-containment match finds nothing and the fallback classifies `model.GetOperation(expression)` of the element alone. A transparent wrapper (parentheses, the null-forgiving `!`) has no operation of its own, so the handle under it is lost and the call is not relevant; a boxing or user-defined element conversion sits on the array element, not on the expression, so a struct handle boxed into `params object[]` or a handle passed through op_Implicit into `params Box[]` yields an opaque-and-relevant slot although nothing of the handle reaches the callee. Witnessed by the hostile cases whose binding is `params` and whose value-flow shape is parens, bang, boxing or user_implicit; casts, `as` and the may-value forms have operations of their own and are classified correctly.",
16-
"status": "open: an implementation defect in the A2 classifier, to be repaired as its own classified change",
17-
"red": "occurrence_not_captured (lost) / fact_without_relevant_occurrence (false)"
18-
},
1912
"F-CONDITIONAL-RECEIVER": {
2013
"class": "case 1",
2114
"title": "a reduced extension receiver under `?.` is not bound to ordinal 0",
@@ -47,6 +40,13 @@
4740
"evidence": "BuildGuardedFacts receives the legacy candidate NAMES and tests `handles.Contains(lr.Local.Name)`; the candidate collector descends into lambda bodies. Two locals spelled alike in sibling scopes, or a lambda-local creation beside an unrelated local of the same spelling, produce a var fact on a symbol that is no candidate: a false raw fact. Witnessed by three hostile cases.",
4841
"status": "closed: A2.2-4R1. BuildGuardedFacts takes symbol sets (SymbolEqualityComparer.Default) recorded at the legacy admission points beside the names; the legacy name-based structures are untouched. The three shadow witnesses are designed green; the oracle's fact_binds_other_symbol check stays armed.",
4942
"red": "fact_binds_other_symbol"
43+
},
44+
"F-PARAMS-ELEMENT": {
45+
"class": "case 1",
46+
"title": "an expanded params element is classified from its bare syntax",
47+
"evidence": "For an expanded params argument the argument operation carries the call's own syntax, so the span-containment match finds nothing and the fallback classifies `model.GetOperation(expression)` of the element alone. A transparent wrapper (parentheses, the null-forgiving `!`) has no operation of its own, so the handle under it is lost and the call is not relevant; a boxing or user-defined element conversion sits on the array element, not on the expression, so a struct handle boxed into `params object[]` or a handle passed through op_Implicit into `params Box[]` yields an opaque-and-relevant slot although nothing of the handle reaches the callee. Witnessed by the hostile cases whose binding is `params` and whose value-flow shape is parens, bang, boxing or user_implicit; casts, `as` and the may-value forms have operations of their own and are classified correctly.",
48+
"status": "closed: A2.2-4R2. ValueOf classifies an expanded params element from the ParamArray argument's array initializer element (its conversion included) instead of the bare syntax; the affected pairwise cases are designed green by the generic rule.",
49+
"red": "occurrence_not_captured (lost) / fact_without_relevant_occurrence (false)"
5050
}
5151
}
5252
}

‎docs/notes/p037-formal-kernel.md‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,12 @@ causes of FACT-DIFF. Tracked in #364 with its own acceptance.
11661166
line: the sidecar's handle and owned-parameter sets are symbol sets recorded
11671167
at the legacy admission points beside the names, the legacy name-based
11681168
structures untouched; the three shadowing witnesses read green, every other
1169-
pinned RED stays, the 52 shapes and the probe are byte-identical;
1169+
pinned RED stays, the 52 shapes and the probe are byte-identical. R2
1170+
landed in the commit carrying this line: an expanded params element is
1171+
classified from the ParamArray argument's array-initializer element, its
1172+
element conversion included, so a handle under parentheses or `!` is no
1173+
longer lost and a boxed or user-converted element no longer yields a false
1174+
slot; the affected pairwise cases read green by the generic design;
11701175
- **A2.2-5** mutation campaign: remove the handle, add parentheses, perturb the
11711176
binding, distinguish nested calls;
11721177
- **A2.2-S** cumulative A2 after-evidence on M1 against the existing R with
@@ -1223,7 +1228,7 @@ does a pinned RED that silently disappears):
12231228
|---|---|---|---|
12241229
| F-MEMBER | 3 | expression-bodied members, struct and record methods, property accessors are outside the legacy admission *and* the orphan carrier (the gates sit inside the class / block-body loop) | probe `Box.op_Implicit`; hostile `member-*` |
12251230
| F-SHADOW | 1 | the guarded-fact handle set was keyed by spelling (`handles.Contains(lr.Local.Name)`) and the candidate collector descends into lambdas: a same-spelled non-candidate in a sibling scope, or beside a lambda-local creation, got a false `var` fact. **Repaired in A2.2-4R1** (10.6.11) | hostile `shadow-*`, now green |
1226-
| F-PARAMS-ELEMENT | 1 | an expanded params element is classified from its bare syntax: under parentheses or `!` the handle is lost (no operation of its own); under a boxing or user-defined element conversion a false opaque-and-relevant slot is emitted | hostile `pw-*-params-*` with parens / bang / boxing / user_implicit |
1231+
| F-PARAMS-ELEMENT | 1 | an expanded params element was classified from its bare syntax: under parentheses or `!` the handle was lost (no operation of its own); under a boxing or user-defined element conversion a false opaque-and-relevant slot was emitted. **Repaired in A2.2-4R2** (10.6.11) | hostile `pw-*-params-*` with parens / bang / boxing / user_implicit, now green |
12271232
| F-CONDITIONAL-RECEIVER | 1 | `r?.Ext(...)` invokes through a member binding, the receiver is read from `MemberAccessExpressionSyntax` only, and ordinal 0 is dropped | hostile `ext-conditional-access` |
12281233
| F-VOCAB | 3 | four argument shapes the frozen list has no name for: a tested operand, an interpolation hole, an indexer argument, a constructor-initializer argument; production correctly emits nothing, the sentence demands a name | hostile `vocab-*` |
12291234

@@ -1279,3 +1284,18 @@ nested-function gap.
12791284
facts are byte-identical; the three shadowing witnesses read green
12801285
(`shadow-lambda-local` now has no fact and no carrier, the truth); every
12811286
other pinned RED stays; inertness and the local rehearsal unchanged.
1287+
- **R2, F-PARAMS-ELEMENT.** In `EmitCall.ValueOf`, when no argument operation
1288+
is attached to the argument's span, the expanded params element is looked
1289+
up in the ParamArray argument's `IArrayCreationOperation` initializer (the
1290+
element whose syntax the argument contains) before falling back to
1291+
`GetOperation` on the bare expression. The element carries its own
1292+
conversion, so the existing walker decides it: `(r)` and `r!` yield the
1293+
local reference (a handle, `opaque` in the params slot, relevant), a struct
1294+
handle into `params object[]` yields a boxing conversion (not a handle) and
1295+
a handle into `params Box[]` a user-defined one (not a handle). The
1296+
collapsed form (an array passed whole) matched by span before and still
1297+
does. Measured: the 52 shapes and the probe byte-identical; the four
1298+
affected pairwise compositions (parens, bang, boxing, user_implicit under an
1299+
expanded params binding, across site forms and carriers) read green by the
1300+
generic design; every other pinned RED stays; inertness and the local
1301+
rehearsal unchanged.

‎frontend/roslyn/OwnSharp.Extractor/Program.cs‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3113,11 +3113,26 @@ void Bind(int ordinal, Dictionary<string, object?> fact, bool handle)
31133113
{
31143114
// Roslyn attaches the argument operation to the INNERMOST expression: for `(r)` and
31153115
// `r!` its Syntax is the identifier `r`, not the ArgumentSyntax, so match by span
3116-
// containment. A params-array or default-value argument carries the invocation's
3117-
// syntax and matches nothing here, which is the fallback below on purpose.
3116+
// containment. A default-value argument carries the invocation's syntax and matches
3117+
// nothing here, which is the fallback below on purpose.
31183118
var bound = boundArgs?.FirstOrDefault(a => argument.Span.Contains(a.Syntax.Span));
31193119
if (bound is null)
3120-
return model.GetOperation(expression);
3120+
{
3121+
// P-037 A2.2-4R2 (F-PARAMS-ELEMENT): an EXPANDED params argument has no argument
3122+
// operation of its own either — the ParamArray argument carries the call's
3123+
// syntax and its value is the array Roslyn builds, whose initializer elements
3124+
// are the arguments' operations, element conversion included (a box, an
3125+
// op_Implicit). Classify that element, never the bare syntax: `(r)` and `r!`
3126+
// have no operation of their own and the handle under them was lost, and a
3127+
// struct handle boxed into `params object[]` classified as the unboxed local.
3128+
var element = boundArgs?
3129+
.Where(a => a.ArgumentKind == ArgumentKind.ParamArray)
3130+
.Select(a => a.Value as IArrayCreationOperation)
3131+
.Where(ac => ac?.Initializer is not null)
3132+
.SelectMany(ac => ac!.Initializer!.ElementValues)
3133+
.FirstOrDefault(e => argument.Span.Contains(e.Syntax.Span));
3134+
return element ?? model.GetOperation(expression);
3135+
}
31213136
if (bound.InConversion.IsUserDefined)
31223137
return null; // a hidden call at the parameter itself: not the handle
31233138
return bound.Value;

‎scripts/p037_hostile_census.py‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -303,18 +303,8 @@ def pairwise_case(s: str, w: str, b: str, c: str) -> tuple[str, str, dict[str, A
303303
"occurrences": occurrences,
304304
"red": {},
305305
}
306-
# F-PARAMS-ELEMENT (corpus/p037-relevance/oracle_findings.json): an expanded params element
307-
# is classified from its bare syntax. A transparent wrapper has no operation of its own, so
308-
# the handle is lost; a boxing or user-defined element conversion is not seen, so a false
309-
# opaque-and-relevant slot is emitted. The design above stays the truth; the RED is pinned.
310-
if b == "params" and w in {"parens", "bang"}:
311-
design["red"] = {"occurrence_not_captured": 1}
312-
design["finding"] = "F-PARAMS-ELEMENT"
313-
design["carrier"] = "functions" if c.startswith("record") else "none"
314-
if b == "params" and w in {"boxing", "user_implicit"}:
315-
design["red"] = {"fact_without_relevant_occurrence": 1}
316-
design["finding"] = "F-PARAMS-ELEMENT"
317-
design["carrier"] = "functions" if c.startswith("record") else "guarded_functions"
306+
# F-PARAMS-ELEMENT (an expanded params element classified from its bare syntax) was pinned
307+
# RED here until A2.2-4R2 repaired it: the design above is the truth for every binding.
318308
return name, src, design
319309

320310

‎spec/OwnIR.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,11 @@ guarded_facts:
378378

379379
Binding rules: a named argument resolves to its parameter; a reduced extension's
380380
receiver is ordinal 0 (the unreduced declaration is the summary's home); an
381-
argument bound to a `params` array collapses to one `opaque` slot; an omitted
382-
optional argument has no entry; a `ref`/`out` argument is `opaque`. For an
381+
argument bound to a `params` array collapses to one `opaque` slot, each
382+
expanded element classified with its own element conversion (P-037 A2.2-4R2:
383+
a handle under parentheses or `!` still flows, a boxed struct handle or one
384+
passed through `op_Implicit` does not); an omitted optional argument has no
385+
entry; a `ref`/`out` argument is `opaque`. For an
383386
**unresolved** callee (`callee: null`) the ordinal is the *source position* —
384387
there is no declaration to bind against, and the record says so rather than
385388
guessing. Calls inside lambdas and local functions belong to those bodies, not

0 commit comments

Comments
 (0)