Skip to content

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

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

xperiandri wants to merge 3 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.

Comment thread RFCs/FS-1031-mixing-ranges-and-values-in-sequences.md Outdated
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.

[ yield 1; 2..3; 4 ] // [1; 2; 3]; 4 is discarded with warning FS3221
```

A list or array whose elements are all ranges or plain expressions is the exception. A plain expression is any expression except a `yield`, `yield!`, `return`, `return!`, `if`, `match`, `try`, `for`, `while`, `let`, `use` or `do` construct. Each plain expression is an element, as in a list literal: `let f c = [ 1; 2..3; c ]` infers `c: int`, as `[ 1; c ]` does. The FS-1069 rule would make `c` a `unit` statement, as in `seq { 1; c }` today.

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.

Can the ruleset be explained simpler as opposed to the negative keyword enumeration?
Aware of the skill for compactness even when doing incremental improvements.

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