Repository navigation
FS-1031: values in a flat list or array stay elements - #860
xperiandri wants to merge 3 commits into
Conversation
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>
There was a problem hiding this comment.
🟡 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.
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>
|
Pushed 6dceb66: the Diagnostics list said an element type mismatch is FS0001. The implementation (dotnet/fsharp#20759) reports the error of the equivalent |
| [ 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. |
There was a problem hiding this comment.
Can the ruleset be explained simpler as opposed to the negative keyword enumeration?
Aware of the skill for compactness even when doing incremental improvements.

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 ]infersc: int, as[ 1; c ]does. The FS-1069 rule alone would makecaunitstatement, as inseq { 1; c }today. The checklist now links the implementation.🤖 Generated with Claude Code