Repository navigation
cst, sema: record spreads (F# 11's RecordSpreads) - #830
Merged
Merged
Conversation
Parse `{ ...e; F = x }`, `{| ...e |}` and `type R = { ...T; F: int }`
as FCS does: new kinds `RECORD_SPREAD`, `RECORD_SPREAD_DECL` and the
`DOT_DOT_DOT_TOK` token, with FCS's error forms (a spread with no source,
FS3899/FS3900; `{ ...e with … }`, FS3903, keeping `e` as the copy source;
`...e` anywhere else, FS3902, as an `ERROR` node standing for its
`ArbitraryAfterError`). The `RecordSpreads` row goes live: a parse-phase
`Legality` gate at each spread, held to FCS's check at 10.0.
The union reads spreads through `spreads()` on `RecordExpr`,
`AnonRecdExpr` and `RecordRepr`, each spread with its index among the
bindings. An ordered item enum would put a new enum in every frozen
facade, which astgen blocks; this shape leaves every published lock
byte-identical.
Sema walks each spread's source, resolves a spread type, declines every
record-label answer past a record with a spread (whose labels it does not
read), and reads no field of such a record. The record-label generator
now spreads records, and the record inference grid and the resolution
corpus hold the declines to FCS.
FCS's parser accepts a dotted field in an anonymous record's
construction, so the parse error for one is gone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
PR 8 step 4a of
docs/ast-versioning-plan.md: F# 11's record spreads (RecordSpreads, dotnet/fsharp#18927), parsed, gated and declined soundly.Parser (
borzoi-cst){ ...e; F = x },{ x with ...e },{ inherit B(); ...e },{| ...e; F = x |},struct {| ...e |}, andtype R = { ...T; F: int }(impl and signature files), as FCS'srecdExprCore,recdBindingandrecdFieldDeclread them.{ ... },{ ...r; ... },{| ... |}: FS3899;type R = { ... }: FS3900);{ ...e with F = x }and{| ...e with … |}: FS3903, withekept as the copy source;...eanywhere else ([ ...xs ],(...x),x, ...y,1 + ...x,{ ...; X = 1 }): FS3902. It parses as anERRORnode that stands for FCS'sArbitraryAfterError, so its slot reads as empty and its expression is unchecked, as in FCS.DOT_DOT_DOT_TOK,RECORD_SPREADandRECORD_SPREAD_DECL....afterwith) came with fcs-dump: FCS 43.13.101, with a frozen legacy oracle below the support floor #813.{| ...r; Nested.B = 1 |}).parsInvalidAnonRecdExpris no longer raised anywhere in FCS, so our parse error for it is gone.diff_ast_anon_recd_dotted_fieldis now FCS-graded.Union and facades
RecordExpr::spreads(),AnonRecdExpr::spreads()andRecordRepr::spreads()each return(index, RecordSpread[Decl]): every spread with its position among the record's bindings, sofields()andspreads()interleave back into FCS's ordered list.RecordExprItem { Field, Spread }) first. astgen derives it into every frozen facade (itsFieldvariant's node exists there) and fails on it as a "new variant". A wholly new enum is classified the same way, so that shape would have neededACCEPTED_DIVERGENCES. The tuple shape adds no line to any published lock.v4_6/v5/v8/v9/v10locks, code and consumer fixtures are byte-identical.union,v11andpreviewgain the two nodes and five accessors.Gate
RecordSpreadsrow is nowKind(RECORD_SPREAD)+Kind(RECORD_SPREAD_DECL),live: a parse-phaseLegalitygate at each spread's...e/...T.check_time_gates_report_what_fcs_checks_reportholds it to FCS's check diagnostics, span and message, at 10.0 / 11.0 / preview, for nominal, generic, anonymous and struct spreads. Below 10.0 the legacy oracle predates spreads.fcs_types_a_legality_gated_file_as_it_does_at_the_features_versionhas a fixture. The anonymous-record spread is left out of it because FCS's generated anonymous type name differs between 10.0 and 11.0; the check-time fixture covers that spread.diagnostic_classes,facade_properties, and a control inparser_diff_feature_gates(from the support floor) show the tree is the same at every version.Sema
Sema declines rather than guesses wherever it does not model spreads:
resolve_diff's corpus.p.Aaftertype R = { ...T }would commit toT.A, where FCS saysR.A.record_label_gen_diff's generator now spreads records, before or after their own fields. Its model of FCS's table (spread labels declared at the spread's type, and the shadowing rules) agrees with FCS on every probe. A new floor, "winners carrying a spread", is 37 at the default seed against a floor of 15.infer_project_record_diffgainsspreadandspreadShadowsrows across every placement and receiver context; inspreadShadowsthe spread replaces an explicitK: stringwithint. Re-enabling field reads makes that grid fail.Manifest movement (every item is a record-spread corpus file)
parser_corpus_diff: the 31 spread files leavefcs-normaliser-unmodelled. 30 match FCS.Expression_Anonymous_NestedUpdates.fsbriefly readwe-reject-fcs-acceptsbecause of the dotted-field error above. It matches now.fslib-extra-pervasives.fsstay as they were, for 4b.parser_corpus: the same 31 files leaveerrors.accessor_coverage:+AnonRecdExpr::spreads,+RecordExpr::spreads,+RecordRepr::spreads,+RecordSpread::expr,+RecordSpreadDecl::ty.version_dependence_census:L(Legality only) at every version below 11.0.RecordSpreads.fsxand the twoCoercionsAppliedfiles keep their existingRcells below 8.0, which come from retired features.recovery_sweep: four newly sampled token deletions in spread files.exactoroutside-damage.Expression_Nominal_NoOverlap_Spread_Explicit.fs@102isdivergent. It deletesNoComparisonfrom a type's attribute list, the same pre-existing attribute-recovery family as the pinnedE_Clashing_Values_in_AbstractClass02.fs@229. It has nothing to do with spreads.resolve_corpus_diff,infer_corpus_diff,attr_resolution_corpus,xml_doc_source_corpus: three spread files move fromour-parse-errorstocompared, with their attribute uses committed or recorded asassembly-gap, and their bindingsagree-none.infer_corpus_dump: the spread files' digests, now that they parse.Checks
cargo test, doc with--document-private-items, and the featureless cst clippy/doc pair.parser_corpus_sweep,xml_doc_shipped_sweepandxml_doc_source_diff::corpus.tools/ci/project-corpus-gate.sh.codex review: no findings.For PR 5 (publishing
v11)v11's surface now differs fromv10's byRecordSpread/RecordSpreadDecland the five accessors, so publishing it writes a distinct facade and consumer fixture, not an alias.v11alone.🤖 Generated with Claude Code