Skip to content

FS-1031: values in a flat list or array stay elements - #860

Open
xperiandri wants to merge 4 commits into
fsharp:mainfrom
xperiandri:rfc/fs-1031-flat-literals
Open

xperiandri wants to merge 4 commits into
fsharp:mainfrom
xperiandri:rfc/fs-1031-flat-literals

Conversation

@xperiandri

Copy link
Copy Markdown
Contributor

A clarification that came out of the implementation, dotnet/fsharp#20759. Rule 2 now says that a list or array of only values and ranges stays a literal, so let f c = [ 1; 2..3; c ] infers c: int, as [ 1; c ] does. The FS-1069 rule alone would make c a unit statement, as in seq { 1; c } today. The checklist now links the implementation.

🤖 Generated with Claude Code

A list or array of only values and ranges stays a literal, so a generic value next to a range is an element and not a unit statement. Also links the implementation PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 10, 2026 23:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new exception does not precisely define which expressions retain literal element typing.

1 open finding
What changed in this PR

Clarifies FS-1031’s interaction with FS-1069 for flat list and array expressions.

Changes:

  • Links the active implementation PR.
  • Specifies that flat values remain elements when mixed with ranges.
File Description
RFCs/​FS-1031-mixing-ranges-and-values-in-sequences.md Adds the literal-preservation exception and implementation link.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

xperiandri and others added 2 commits October 15, 2026 02:12
Name the constructs that are not plain expressions, so the exception to the FS-1069 rule has an exact boundary.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The implementation reports the error of the equivalent yield! (FS0193 in list, array and sequence expressions), not FS0001.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xperiandri

Copy link
Copy Markdown
Contributor Author

Pushed 6dceb66: the Diagnostics list said an element type mismatch is FS0001. The implementation (dotnet/fsharp#20759) reports the error of the equivalent yield!, which is FS0193 in list, array and sequence expressions ([ 1; 2.0..3.0 ]), so the line now says that instead of naming a code.

… list

Rule 2 now says a list or array of only ranges and non-statement expressions keeps literal typing, and names the statements by reference to rule 1. The keyword enumeration is gone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xperiandri

xperiandri commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

@T-Gro a suggestion for the Scaling section, based on the benchmarks added in dotnet/fsharp#20759.

Scaling says checking MUST stay linear in the number of elements. It does not for any collection that goes through the sequence-expression checker, and one range among the elements sends a flat list or array there. Checking a list of Count elements (a range at every tenth one in the mixed and explicit forms), local Release build:

Count flat literal mixed ranges explicit yield!
250 128 ms 201 ms 216 ms
500 121 ms 467 ms 546 ms
1000 92 ms 1,723 ms 1,944 ms

The two computed forms grow about 4x per doubling and cost the same, so this is the existing cost of yield!, not something the feature adds. Suggested last sentence of Scaling:

-Checking MUST stay linear in it.
+Checking MUST NOT cost more than the equivalent `yield!` form.

Making the checker itself linear would be a separate change, tracked in dotnet/fsharp#20887. Shall I put the softened sentence into this PR?

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.

3 participants