Skip to content
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1799aaf
make attribute targets mismatches a warning and not an error.
edgarfgp Apr 23, 2025
55507e9
release notes
edgarfgp Apr 23, 2025
1738018
update tests
edgarfgp Apr 23, 2025
65f5bb6
Merge branch 'main' into fix-attr-targets
edgarfgp Apr 24, 2025
0c97b9d
Merge branch 'main' into fix-attr-targets
edgarfgp Apr 27, 2025
6f2b706
update baselines
edgarfgp Apr 29, 2025
e8f1bb0
Merge branch 'main' into fix-attr-targets
edgarfgp Apr 29, 2025
75d8f5e
Update baselines
edgarfgp Apr 29, 2025
4f2e97e
Merge branch 'fix-attr-targets' of github.com:edgarfgp/fsharp into fi…
edgarfgp Apr 29, 2025
63be5d5
Merge branch 'main' into fix-attr-targets
edgarfgp Apr 30, 2025
4248f2a
Move attribute form logic to an AP
edgarfgp Apr 30, 2025
cc96217
Merge branch 'main' into fix-attr-targets
edgarfgp May 1, 2025
e270b88
Merge branch 'main' into fix-attr-targets
edgarfgp May 1, 2025
e0cc65a
Merge branch 'main' into fix-attr-targets
edgarfgp May 2, 2025
1e29d58
Merge branch 'main' into fix-attr-targets
edgarfgp May 5, 2025
1470bf9
Merge branch 'main' into fix-attr-targets
edgarfgp May 6, 2025
8988215
Merge branch 'main' into fix-attr-targets
edgarfgp May 7, 2025
74712e8
Merge branch 'main' into fix-attr-targets
edgarfgp May 12, 2025
967c4a9
Merge branch 'main' of github.com:edgarfgp/fsharp
edgarfgp May 13, 2025
a30cef4
Merge branch 'dotnet:main' into main
edgarfgp May 22, 2025
5fa0480
Merge branch 'dotnet:main' into main
edgarfgp May 24, 2025
15e3d34
Merge branch 'dotnet:main' into main
edgarfgp May 29, 2025
b7ffcf8
Merge branch 'dotnet:main' into main
edgarfgp Jun 6, 2025
5bde641
Merge branch 'dotnet:main' into main
edgarfgp Jul 26, 2025
0f7c23c
Merge branch 'dotnet:main' into main
edgarfgp Jul 29, 2025
6a6843c
Merge branch 'dotnet:main' into main
edgarfgp Aug 4, 2025
d11dd4a
Merge branch 'dotnet:main' into main
edgarfgp Aug 4, 2025
30fc9a2
Merge branch 'dotnet:main' into main
edgarfgp Aug 5, 2025
835d645
Unify let, let!, use, use! LetOrUse AST representation.
edgarfgp Aug 5, 2025
6dcde2e
Fix computation expression pattern matching order
edgarfgp Aug 6, 2025
77aff92
Merge branch 'main' into unify-let-or-use-2
edgarfgp Aug 6, 2025
670aab8
format
edgarfgp Aug 7, 2025
a862ad1
release notes
edgarfgp Aug 7, 2025
cfb3d09
ILVerify
edgarfgp Aug 7, 2025
918f3e6
Fix computation expression pattern matching order
edgarfgp Aug 7, 2025
fcef811
update baselines
edgarfgp Aug 7, 2025
4d57d09
Fix SynPat shouldBeParenthesizedInContext
edgarfgp Aug 7, 2025
af8bf5a
Merge branch 'unify-let-or-use-2' of github.com:edgarfgp/fsharp into …
edgarfgp Aug 7, 2025
d3bac4a
Update SynPat.fs
edgarfgp Aug 7, 2025
0ceae7b
Attempt to fix editor test
edgarfgp Aug 8, 2025
2181367
Merge branch 'unify-let-or-use-2' of github.com:edgarfgp/fsharp into …
edgarfgp Aug 8, 2025
ca1c516
Simplify mkLetExpression
edgarfgp Aug 8, 2025
47429e6
one more test
edgarfgp Aug 8, 2025
a9f08ae
Add comments to explain the meaning of the new flags
edgarfgp Aug 8, 2025
121a373
Update to always use named fields
edgarfgp Aug 8, 2025
b1ed90b
document isFromSource
edgarfgp Aug 8, 2025
2f268f9
Rename isComputed to isBang
edgarfgp Aug 8, 2025
815c51b
Merge branch 'dotnet:main' into main
edgarfgp Aug 11, 2025
b57b244
Merge branch 'main' into unify-let-or-use-2
edgarfgp Aug 11, 2025
f6fa86e
update baselines
edgarfgp Aug 11, 2025
f1a2727
Release notes: add migration guidance
edgarfgp Aug 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/10.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

### Changed
* Use `errorR` instead of `error` in `CheckDeclarations.fs` when possible. ([PR #18645](https://github.com/dotnet/fsharp/pull/18645))
* Unify `let`, `let!`, `use` and `use!` AST representation. ([PR #18825](https://github.com/dotnet/fsharp/pull/18825))

### Breaking Changes

Expand Down
11 changes: 10 additions & 1 deletion src/Compiler/Checking/CheckRecordSyntaxHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,13 @@ let BindOriginalRecdExpr (withExpr: SynExpr * BlockSeparator) mkRecdExpr =
None,
SynBindingTrivia.Zero)

SynExpr.LetOrUse(false, false, [ binding ], mkRecdExpr (Some withExpr), mOrigExprSynth, SynExprLetOrUseTrivia.Zero)
SynExpr.LetOrUse(
isRecursive = false,
isUse = false,
isFromSource = false, // compiler generated during desugaring
isBang = false,
bindings = [ binding ],
body = mkRecdExpr (Some withExpr),
range = mOrigExprSynth,
trivia = SynExprLetOrUseTrivia.Zero
)
309 changes: 230 additions & 79 deletions src/Compiler/Checking/Expressions/CheckComputationExpressions.fs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/Compiler/Checking/Expressions/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6072,7 +6072,7 @@ and TcExprUndelayed (cenv: cenv) (overallTy: OverallTy) env tpenv (synExpr: SynE
| SynExpr.DoBang (trivia = { DoBangKeyword = m })
| SynExpr.MatchBang (trivia = { MatchBangKeyword = m })
| SynExpr.WhileBang (range = m)
| SynExpr.LetOrUseBang (trivia = { LetOrUseKeyword = m }) ->
| SynExpr.LetOrUse (isBang = true; trivia = { LetOrUseKeyword = m }) ->
error(Error(FSComp.SR.tcConstructRequiresComputationExpression(), m))

| SynExpr.IndexFromEnd (rightExpr, m) ->
Expand Down Expand Up @@ -9199,7 +9199,7 @@ and TcImplicitOpItemThen (cenv: cenv) overallTy env id sln tpenv mItem delayed =
| SynExpr.YieldOrReturn _
| SynExpr.YieldOrReturnFrom _
| SynExpr.MatchBang _
| SynExpr.LetOrUseBang _
| SynExpr.LetOrUse (isBang = true)
| SynExpr.DoBang _
| SynExpr.WhileBang _
| SynExpr.TraitCall _
Expand Down Expand Up @@ -10614,7 +10614,7 @@ and TcLinearExprs bodyChecker cenv env overallTy tpenv isCompExpr synExpr cont =
TcLinearExprs bodyChecker cenv env2 overallTy tpenv isCompExpr expr2 (fun (expr2R, tpenv) ->
cont (Expr.Sequential (expr1R, expr2R, NormalSeq, m), tpenv))

| SynExpr.LetOrUse (isRec, isUse, binds, body, m, _) when not (isUse && isCompExpr) ->
| SynExpr.LetOrUse (isRecursive = isRec; isUse= isUse; bindings = binds; body = body; range = m) when not (isUse && isCompExpr) ->
if isRec then
// TcLinearExprs processes at most one recursive binding, this is not tailcalling
CheckRecursiveBindingIds binds
Expand Down
6 changes: 1 addition & 5 deletions src/Compiler/Checking/Expressions/CheckExpressionsOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,6 @@ let YieldFree (cenv: TcFileState) expr =
| SynExpr.While(doExpr = body)
| SynExpr.WhileBang(doExpr = body)
| SynExpr.ForEach(bodyExpr = body) -> YieldFree body

| SynExpr.LetOrUseBang(body = body) -> YieldFree body

| SynExpr.YieldOrReturn(flags = (true, _)) -> false

| _ -> true
Expand Down Expand Up @@ -232,7 +229,7 @@ let YieldFree (cenv: TcFileState) expr =
| SynExpr.WhileBang(doExpr = body)
| SynExpr.ForEach(bodyExpr = body) -> YieldFree body

| SynExpr.LetOrUseBang _
| SynExpr.LetOrUse(isBang = true)
| SynExpr.YieldOrReturnFrom _
| SynExpr.YieldOrReturn _
| SynExpr.ImplicitZero _
Expand All @@ -256,7 +253,6 @@ let inline IsSimpleSemicolonSequenceElement expr cenv acceptDeprecated =
| SynExpr.LetOrUse _
| SynExpr.Do _
| SynExpr.MatchBang _
| SynExpr.LetOrUseBang _
| SynExpr.While _
| SynExpr.WhileBang _ -> false
| _ -> true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ let TcSequenceExpression (cenv: TcFileState) env tpenv comp (overallTy: OverallT
// The 'mBind' is attached to the lambda
Some(mkSeqUsing cenv env wholeExprMark bindPatTy genOuterTy inputExpr consumeExpr, tpenv)

| SynExpr.LetOrUseBang(range = m) -> error (Error(FSComp.SR.tcUseForInSequenceExpression (), m))
| SynExpr.LetOrUse(isBang = true; range = m) -> error (Error(FSComp.SR.tcUseForInSequenceExpression (), m))

| SynExpr.Match(spMatch, expr, clauses, _m, _trivia) ->
let inputExpr, inputTy, tpenv = TcExprOfUnknownType cenv env tpenv expr
Expand Down
15 changes: 0 additions & 15 deletions src/Compiler/Driver/GraphChecking/FileContentMapping.fs
Original file line number Diff line number Diff line change
Expand Up @@ -505,21 +505,6 @@ let visitSynExpr (e: SynExpr) : FileContentEntry list =
Continuation.concatenate continuations continuation
| SynExpr.YieldOrReturn(expr = expr) -> visit expr continuation
| SynExpr.YieldOrReturnFrom(expr = expr) -> visit expr continuation
| SynExpr.LetOrUseBang(pat = pat; rhs = rhs; andBangs = andBangs; body = body) ->
let continuations =
let andBangExprs = List.map (fun (SynBinding(expr = body)) -> body) andBangs
List.map visit (body :: rhs :: andBangExprs)

let finalContinuation nodes =
[
yield! List.concat nodes
yield! visitPat pat
for SynBinding(headPat = pat) in andBangs do
yield! visitPat pat
]
|> continuation

Continuation.sequence continuations finalContinuation
| SynExpr.MatchBang(expr = expr; clauses = clauses) ->
visit expr (fun exprNodes ->
[ yield! exprNodes; yield! List.collect visitSynMatchClause clauses ]
Expand Down
9 changes: 0 additions & 9 deletions src/Compiler/Service/FSharpParseFileResults.fs
Original file line number Diff line number Diff line change
Expand Up @@ -762,15 +762,6 @@ type FSharpParseFileResults(diagnostics: FSharpDiagnostic[], input: ParsedInput,
yield! walkExpr false e2
yield! walkExpr false e3

| SynExpr.LetOrUseBang(spBind, _, _, _, rhsExpr, andBangs, bodyExpr, _, _) ->
yield! walkBindSeqPt spBind
yield! walkExpr true rhsExpr

for SynBinding(debugPoint = andBangSpBind; expr = eAndBang) in andBangs do
yield! walkBindSeqPt andBangSpBind
yield! walkExpr true eAndBang

yield! walkExpr true bodyExpr
]

// Process a class declaration or F# type declaration
Expand Down
9 changes: 0 additions & 9 deletions src/Compiler/Service/ServiceInterfaceStubGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -956,15 +956,6 @@ module InterfaceStubGenerator =
| SynExpr.YieldOrReturnFrom(expr = synExpr)
| SynExpr.DoBang(expr = synExpr) -> walkExpr synExpr

| SynExpr.LetOrUseBang(rhs = synExpr1; andBangs = synExprAndBangs; body = synExpr2) ->
[
yield synExpr1
for SynBinding(expr = eAndBang) in synExprAndBangs do
yield eAndBang
yield synExpr2
]
|> List.tryPick walkExpr

| SynExpr.LibraryOnlyILAssembly _
| SynExpr.LibraryOnlyStaticOptimization _
| SynExpr.LibraryOnlyUnionCaseFieldGet _
Expand Down
14 changes: 0 additions & 14 deletions src/Compiler/Service/ServiceParseTreeWalk.fs
Original file line number Diff line number Diff line change
Expand Up @@ -745,20 +745,6 @@ module SyntaxTraversal =
]
|> pick expr

| SynExpr.LetOrUseBang(pat = synPat; rhs = synExpr; andBangs = andBangSynExprs; body = synExpr2) ->
[
yield dive synPat synPat.Range traversePat
yield dive synExpr synExpr.Range traverseSynExpr
yield!
[
for SynBinding(headPat = andBangSynPat; expr = andBangSynExpr) in andBangSynExprs do
yield (dive andBangSynPat andBangSynPat.Range traversePat)
yield (dive andBangSynExpr andBangSynExpr.Range traverseSynExpr)
]
yield dive synExpr2 synExpr2.Range traverseSynExpr
]
|> pick expr

| SynExpr.Dynamic _
| SynExpr.Ident _
| SynExpr.LongIdent _
Expand Down
19 changes: 0 additions & 19 deletions src/Compiler/Service/ServiceParsedInputOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -848,15 +848,6 @@ module ParsedInput =

| SynExpr.Ident ident -> ifPosInRange ident.idRange (fun _ -> Some(EntityKind.FunctionOrValue false))

| SynExpr.LetOrUseBang(rhs = e1; andBangs = es; body = e2) ->
[
yield e1
for SynBinding(expr = eAndBang) in es do
yield eAndBang
yield e2
]
|> List.tryPick (walkExprWithKind parentKind)

| SynExpr.TraitCall(TypesForTypar ts, sign, e, _) ->
List.tryPick walkType ts
|> Option.orElseWith (fun () -> walkMemberSig sign)
Expand Down Expand Up @@ -2155,16 +2146,6 @@ module ParsedInput =
walkExpr e2
walkExpr e3

| SynExpr.LetOrUseBang(pat = pat; rhs = e1; andBangs = es; body = e2) ->
walkPat pat
walkExpr e1

for SynBinding(headPat = patAndBang; expr = eAndBang) in es do
walkPat patAndBang
walkExpr eAndBang

walkExpr e2

| SynExpr.TraitCall(TypesForTypar ts, sign, e, _) ->
List.iter walkType ts
walkMemberSig sign
Expand Down
19 changes: 0 additions & 19 deletions src/Compiler/Service/ServiceStructure.fs
Original file line number Diff line number Diff line change
Expand Up @@ -258,25 +258,6 @@ module Structure =
rcheck Scope.Do Collapse.Below r <| Range.modStart 3 r
parseExpr e

| SynExpr.LetOrUseBang(pat = pat; rhs = eLet; andBangs = es; body = eBody) ->
let exprs =
[
eLet
for SynBinding(expr = eAndBang) in es do
eAndBang
]

for e in exprs do
// for `let!`, `use!` or `and!` the pattern begins at the end of the
// keyword so that this scope can be used without adjustment if there is no `=`
// on the same line. If there is an `=` the range will be adjusted during the
// tooltip creation
let r = Range.endToEnd pat.Range e.Range
rcheck Scope.LetOrUseBang Collapse.Below r r
parseExpr e

parseExpr eBody

| SynExpr.For(doBody = e; range = r)
| SynExpr.ForEach(_, _, _, _, _, _, e, r) ->
rcheck Scope.For Collapse.Below r r
Expand Down
5 changes: 1 addition & 4 deletions src/Compiler/Service/SynExpr.fs
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,7 @@ module SynExpr =
[<return: Struct>]
let (|LetOrUse|_|) =
dangling (function
| SynExpr.LetOrUse _
| SynExpr.LetOrUseBang _ as expr -> Some expr
| SynExpr.LetOrUse _ as expr -> Some expr
| _ -> None)

/// Matches a dangling sequential expression.
Expand Down Expand Up @@ -697,7 +696,6 @@ module SynExpr =
| _, SyntaxNode.SynExpr(SynExpr.Lazy _ as outer) :: _
| _, SyntaxNode.SynExpr(SynExpr.App(argExpr = SynExpr.Paren(expr = Is expr)) as outer) :: _
| _, SyntaxNode.SynExpr(SynExpr.LetOrUse _ as outer) :: _
| _, SyntaxNode.SynExpr(SynExpr.LetOrUseBang _ as outer) :: _
| _, SyntaxNode.SynExpr(SynExpr.TryWith _ as outer) :: _
| _, SyntaxNode.SynExpr(SynExpr.TryFinally _ as outer) :: _
| _, SyntaxNode.SynExpr(SynExpr.For _ as outer) :: _
Expand Down Expand Up @@ -1211,7 +1209,6 @@ module SynExpr =
| SynExpr.Match _, _
| SynExpr.MatchBang _, _
| SynExpr.LetOrUse _, _
| SynExpr.LetOrUseBang _, _
| SynExpr.Sequential _, _
| SynExpr.Do _, _
| SynExpr.DoBang _, _
Expand Down
15 changes: 10 additions & 5 deletions src/Compiler/Service/SynPat.fs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,17 @@ module SynPat =
// set (x: …, y: …) = …
| SynPat.Typed _, SyntaxNode.SynPat(Rightmost(SynPat.Paren(Is pat, _))) :: SyntaxNode.SynMatchClause _ :: _
| Rightmost(SynPat.Typed _), SyntaxNode.SynMatchClause _ :: _
| SynPat.Typed _, SyntaxNode.SynExpr(SynExpr.LetOrUseBang _) :: _
| SynPat.Typed _, SyntaxNode.SynPat(SynPat.Tuple(isStruct = false)) :: SyntaxNode.SynExpr(SynExpr.LetOrUseBang _) :: _
| SynPat.Tuple(isStruct = false; elementPats = AnyTyped), SyntaxNode.SynExpr(SynExpr.LetOrUseBang _) :: _
| SynPat.Typed _, SyntaxNode.SynExpr(SynExpr.LetOrUse(isBang = true)) :: _
| SynPat.Typed _, SyntaxNode.SynPat(SynPat.Tuple(isStruct = false)) :: SyntaxNode.SynExpr(SynExpr.LetOrUse(isBang = true)) :: _
| SynPat.Tuple(isStruct = false; elementPats = AnyTyped), SyntaxNode.SynExpr(SynExpr.LetOrUse(isBang = true)) :: _
| SynPat.Typed _, SyntaxNode.SynPat(SynPat.Tuple(isStruct = false)) :: SyntaxNode.SynBinding _ :: _
| SynPat.Tuple(isStruct = false; elementPats = AnyTyped), SyntaxNode.SynBinding _ :: _

// let! (_ : obj) = …
| SynPat.Typed _, SyntaxNode.SynBinding _ :: SyntaxNode.SynExpr(SynExpr.LetOrUse(isBang = true)) :: _ -> true

// let! (A _) = …
| SynPat.LongIdent _, SyntaxNode.SynBinding _ :: SyntaxNode.SynExpr(SynExpr.LetOrUse(isBang = true)) :: _ -> false
| SynPat.LongIdent(argPats = SynArgPats.Pats(_ :: _)), SyntaxNode.SynBinding _ :: _
| SynPat.LongIdent(argPats = SynArgPats.Pats(_ :: _)), SyntaxNode.SynExpr(SynExpr.Lambda _) :: _
| SynPat.Tuple(isStruct = false), SyntaxNode.SynExpr(SynExpr.Lambda(parsedData = Some _)) :: _
Expand Down Expand Up @@ -144,7 +150,6 @@ module SynPat =

| SyntaxNode.SynExpr(SynExpr.Lambda(body = rhs)) :: _
| SyntaxNode.SynExpr(SynExpr.LetOrUse(body = rhs)) :: _
| SyntaxNode.SynExpr(SynExpr.LetOrUseBang(body = rhs)) :: _
| SyntaxNode.SynBinding(SynBinding(expr = rhs)) :: _
| SyntaxNode.SynMatchClause(SynMatchClause(resultExpr = rhs)) :: _ ->
let rhsRange = rhs.Range
Expand Down Expand Up @@ -243,7 +248,7 @@ module SynPat =
// fun (x) -> …
| _, SyntaxNode.SynBinding _ :: _
| _, SyntaxNode.SynExpr(SynExpr.ForEach _) :: _
| _, SyntaxNode.SynExpr(SynExpr.LetOrUseBang _) :: _
| _, SyntaxNode.SynExpr(SynExpr.LetOrUse(isBang = true)) :: _
| _, SyntaxNode.SynMatchClause _ :: _
| Atomic, SyntaxNode.SynExpr(SynExpr.Lambda(parsedData = Some _)) :: _ -> false

Expand Down
Loading
Loading