Skip to content
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 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
07415ea
Unify `SynExprLetOrUse` trivia
edgarfgp Aug 2, 2025
901cee9
Unify `SynExprLetOrUse` trivia
edgarfgp Aug 2, 2025
152c720
Merge branch 'main' into unify-let-or-use-trivia
edgarfgp Aug 2, 2025
539d9f6
Merge branch 'unify-let-or-use-trivia' of github.com:edgarfgp/fsharp …
edgarfgp Aug 2, 2025
adfa812
remove unused mEquals
edgarfgp Aug 2, 2025
5fa187d
update baselines
edgarfgp Aug 2, 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
2 changes: 1 addition & 1 deletion buildtools/fslex/fslexast.fs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ let GetSpecificUnicodeChars() =

let GetSingleCharAlphabet: Parser<Set<char>> = fun ctx ->
if ctx.unicode
then Set.ofList [ yield! { char 0 .. char <| numLowUnicodeChars-1 }
then Set.ofList [ yield! seq { char 0 .. char <| numLowUnicodeChars-1 }
yield! GetSpecificUnicodeChars() ]
else Set.ofList [ char 0 .. char 255 ]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ let (|ExprAsUseBang|_|) expr =
rhs = rhsExpr
andBangs = andBangs
body = innerComp
trivia = { LetOrUseBangKeyword = mBind }) -> ValueSome(spBind, isFromSource, pat, rhsExpr, andBangs, innerComp, mBind)
trivia = { LetOrUseKeyword = mBind }) -> ValueSome(spBind, isFromSource, pat, rhsExpr, andBangs, innerComp, mBind)
| _ -> ValueNone

[<return: Struct>]
Expand All @@ -875,7 +875,7 @@ let (|ExprAsLetBang|_|) expr =
rhs = letRhsExpr
andBangs = andBangBindings
body = innerComp
trivia = { LetOrUseBangKeyword = mBind }) -> ValueSome(spBind, isFromSource, letPat, letRhsExpr, andBangBindings, innerComp, mBind)
trivia = { LetOrUseKeyword = mBind }) -> ValueSome(spBind, isFromSource, letPat, letRhsExpr, andBangBindings, innerComp, mBind)
| _ -> ValueNone

// "cexpr; cexpr" is treated as builder.Combine(cexpr1, cexpr1)
Expand Down Expand Up @@ -1393,7 +1393,7 @@ let rec TryTranslateComputationExpression
[],
setCondExpr,
mGuard,
SynExprLetOrUseBangTrivia.Zero
SynExprLetOrUseTrivia.Zero
)

let whileExpr =
Expand Down Expand Up @@ -1422,7 +1422,7 @@ let rec TryTranslateComputationExpression
[],
body,
mGuard,
SynExprLetOrUseBangTrivia.Zero
SynExprLetOrUseTrivia.Zero
)

TryTranslateComputationExpression ceenv CompExprTranslationPass.Initial q varSpace rewrittenWhileExpr translatedCtxt
Expand Down Expand Up @@ -1637,7 +1637,7 @@ let rec TryTranslateComputationExpression
[],
innerComp2,
m,
SynExprLetOrUseBangTrivia.Zero
SynExprLetOrUseTrivia.Zero
))
translatedCtxt
)
Expand Down Expand Up @@ -2393,7 +2393,7 @@ and ConsumeCustomOpClauses
[],
contExpr,
intoPat.Range,
SynExprLetOrUseBangTrivia.Zero
SynExprLetOrUseTrivia.Zero
)
else
SynExpr.ForEach(
Expand Down Expand Up @@ -2434,7 +2434,7 @@ and ConsumeCustomOpClauses
[],
compClausesExpr,
compClausesExpr.Range,
SynExprLetOrUseBangTrivia.Zero
SynExprLetOrUseTrivia.Zero
)
else
SynExpr.ForEach(
Expand Down Expand Up @@ -2697,7 +2697,7 @@ and TranslateComputationExpression (ceenv: ComputationExpressionContext<'a>) fir
[],
bodyExpr,
m,
SynExprLetOrUseBangTrivia.Zero
SynExprLetOrUseTrivia.Zero
)

TranslateComputationExpression ceenv CompExprTranslationPass.Initial q varSpace letBangBind translatedCtxt
Expand Down
2 changes: 1 addition & 1 deletion 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 = { LetOrUseBangKeyword = m }) ->
| SynExpr.LetOrUseBang (trivia = { LetOrUseKeyword = m }) ->
error(Error(FSComp.SR.tcConstructRequiresComputationExpression(), m))

| SynExpr.IndexFromEnd (rightExpr, m) ->
Expand Down
11 changes: 9 additions & 2 deletions src/Compiler/SyntaxTree/ParseHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1071,9 +1071,10 @@ let mkLetExpression
// Create let! or use! expression
let spBind = DebugPointAtBinding.Yes(unionRanges mKeyword rhs.Range)

let trivia: SynExprLetOrUseBangTrivia =
let trivia: SynExprLetOrUseTrivia =
{
LetOrUseBangKeyword = mKeyword
LetOrUseKeyword = mKeyword
InKeyword = mIn
EqualsRange = mEquals
}
// isFromSource is true for user-written code
Expand Down Expand Up @@ -1106,6 +1107,11 @@ let mkLetExpression
| SynBinding(trivia = trivia) :: _ -> trivia.LeadingKeyword.Range
| _ -> range0

let mEquals =
match decls with
| SynBinding(trivia = trivia) :: _ -> trivia.EqualsRange
| _ -> None

SynExpr.LetOrUse(
isRec,
isUse, // Pass through the isUse flag from binding info
Expand All @@ -1115,6 +1121,7 @@ let mkLetExpression
{
LetOrUseKeyword = mLetOrUse
InKeyword = mIn'
EqualsRange = mEquals
}
)
| None -> SynExpr.FromParseError(body, mWhole)
2 changes: 1 addition & 1 deletion src/Compiler/SyntaxTree/SyntaxTree.fs
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ type SynExpr =
andBangs: SynExprAndBang list *
body: SynExpr *
range: range *
trivia: SynExprLetOrUseBangTrivia
trivia: SynExprLetOrUseTrivia

| MatchBang of
matchDebugPoint: DebugPointAtBinding *
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/SyntaxTree/SyntaxTree.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ type SynExpr =
andBangs: SynExprAndBang list *
body: SynExpr *
range: range *
trivia: SynExprLetOrUseBangTrivia
trivia: SynExprLetOrUseTrivia

/// F# syntax: match! expr with pat1 -> expr | ... | patN -> exprN
| MatchBang of
Expand Down
13 changes: 1 addition & 12 deletions src/Compiler/SyntaxTree/SyntaxTrivia.fs
Original file line number Diff line number Diff line change
Expand Up @@ -94,24 +94,13 @@ type SynExprLetOrUseTrivia =
{
LetOrUseKeyword: range
InKeyword: range option
EqualsRange: range option
}

static member Zero: SynExprLetOrUseTrivia =
{
InKeyword = None
LetOrUseKeyword = range0
}

[<NoEquality; NoComparison>]
type SynExprLetOrUseBangTrivia =
{
LetOrUseBangKeyword: range
EqualsRange: range option
}

static member Zero: SynExprLetOrUseBangTrivia =
{
LetOrUseBangKeyword = range0
EqualsRange = None
}

Expand Down
12 changes: 1 addition & 11 deletions src/Compiler/SyntaxTree/SyntaxTrivia.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,11 @@ type SynExprLetOrUseTrivia =
LetOrUseKeyword: range
/// The syntax range of the `in` keyword.
InKeyword: range option
}

static member Zero: SynExprLetOrUseTrivia

/// Represents additional information for SynExpr.LetOrUseBang
[<NoEquality; NoComparison>]
type SynExprLetOrUseBangTrivia =
{
/// The syntax range of the `let!` or `use!` keyword.
LetOrUseBangKeyword: range
/// The syntax range of the `=` token.
EqualsRange: range option
}

static member Zero: SynExprLetOrUseBangTrivia
static member Zero: SynExprLetOrUseTrivia

/// Represents additional information for SynExpr.Match
[<NoEquality; NoComparison>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ ImplFile
EqualsRange = Some (3,21--3,22) })],
Const (Unit, (4,4--4,6)), (3,4--4,6),
{ LetOrUseKeyword = (3,4--3,7)
InKeyword = None }), (2,11--2,16), NoneAtLet,
{ LeadingKeyword = Let (2,0--2,3)
InlineKeyword = Some (2,4--2,10)
EqualsRange = Some (2,17--2,18) })], (2,0--4,6))],
InKeyword = None
EqualsRange = Some (3,21--3,22) }), (2,11--2,16),
NoneAtLet, { LeadingKeyword = Let (2,0--2,3)
InlineKeyword = Some (2,4--2,10)
EqualsRange = Some (2,17--2,18) })], (2,0--4,6))],
PreXmlDocEmpty, [], None, (2,0--5,0), { LeadingKeyword = None })],
(true, true), { ConditionalDirectives = []
WarnDirectives = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ ImplFile
EqualsRange = Some (3,10--3,11) })],
Const (Unit, (4,4--4,6)), (3,4--4,6),
{ LetOrUseKeyword = (3,4--3,7)
InKeyword = None }), (2,0--4,6)), (2,0--4,6))],
PreXmlDocEmpty, [], None, (2,0--5,0), { LeadingKeyword = None })],
(true, true), { ConditionalDirectives = []
WarnDirectives = []
CodeComments = [] }, set []))
InKeyword = None
EqualsRange = Some (3,10--3,11) }), (2,0--4,6)),
(2,0--4,6))], PreXmlDocEmpty, [], None, (2,0--5,0),
{ LeadingKeyword = None })], (true, true),
{ ConditionalDirectives = []
WarnDirectives = []
CodeComments = [] }, set []))
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ ImplFile
EqualsRange = Some (3,15--3,16) })],
Const (Unit, (4,4--4,6)), (3,4--4,6),
{ LetOrUseKeyword = (3,4--3,7)
InKeyword = None }), (2,0--4,6)), (2,0--4,6))],
PreXmlDocEmpty, [], None, (2,0--5,0), { LeadingKeyword = None })],
(true, true), { ConditionalDirectives = []
WarnDirectives = []
CodeComments = [] }, set []))
InKeyword = None
EqualsRange = Some (3,15--3,16) }), (2,0--4,6)),
(2,0--4,6))], PreXmlDocEmpty, [], None, (2,0--5,0),
{ LeadingKeyword = None })], (true, true),
{ ConditionalDirectives = []
WarnDirectives = []
CodeComments = [] }, set []))
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ ImplFile
EqualsRange = Some (3,12--3,13) })],
Const (Unit, (4,4--4,6)), (3,4--4,6),
{ LetOrUseKeyword = (3,4--3,7)
InKeyword = None }), (2,4--2,5), NoneAtLet,
InKeyword = None
EqualsRange = Some (3,12--3,13) }), (2,4--2,5), NoneAtLet,
{ LeadingKeyword = Let (2,0--2,3)
InlineKeyword = None
EqualsRange = Some (2,6--2,7) })], (2,0--4,6))],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ ImplFile
YieldOrReturn
((false, true), Ident bar, (6,4--6,14),
{ YieldOrReturnKeyword = (6,4--6,10) }), (3,4--6,14),
{ LetOrUseBangKeyword = (3,4--3,8)
{ LetOrUseKeyword = (3,4--3,8)
InKeyword = None
EqualsRange = Some (3,13--3,14) }), (2,6--7,1)),
(2,0--7,1)), (2,0--7,1))], PreXmlDocEmpty, [], None, (2,0--7,1),
{ LeadingKeyword = None })], (true, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ ImplFile
YieldOrReturn
((false, true), Ident bar, (7,4--7,14),
{ YieldOrReturnKeyword = (7,4--7,10) }), (3,4--7,14),
{ LetOrUseBangKeyword = (3,4--3,8)
{ LetOrUseKeyword = (3,4--3,8)
InKeyword = None
EqualsRange = Some (3,13--3,14) }), (2,6--8,1)),
(2,0--8,1)), (2,0--8,1))], PreXmlDocEmpty, [], None, (2,0--8,1),
{ LeadingKeyword = None })], (true, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ ImplFile
(5,6--5,7)), Ident x, (5,4--5,7)), Ident y,
(5,4--5,9)), (4,4--5,9),
{ LetOrUseKeyword = (4,4--4,7)
InKeyword = Some (4,14--4,16) }), (3,4--5,9),
InKeyword = Some (4,14--4,16)
EqualsRange = Some (4,10--4,11) }), (3,4--5,9),
{ LetOrUseKeyword = (3,4--3,7)
InKeyword = Some (3,14--3,16) }), (2,4--2,8), NoneAtLet,
InKeyword = Some (3,14--3,16)
EqualsRange = Some (3,10--3,11) }), (2,4--2,8), NoneAtLet,
{ LeadingKeyword = Let (2,0--2,3)
InlineKeyword = None
EqualsRange = Some (2,9--2,10) })], (2,0--5,9))],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ ImplFile
YieldOrReturn
((false, true), Const (Unit, (5,11--5,13)), (5,4--5,13),
{ YieldOrReturnKeyword = (5,4--5,10) }), (3,4--5,13),
{ LetOrUseBangKeyword = (3,4--3,8)
{ LetOrUseKeyword = (3,4--3,8)
InKeyword = None
EqualsRange = Some (3,11--3,12) }), (2,5--6,1)),
(2,0--6,1)), (2,0--6,1))], PreXmlDocEmpty, [], None, (2,0--6,1),
{ LeadingKeyword = None })], (true, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ ImplFile
EqualsRange = Some (2,6--2,7) })],
Const (Unit, (2,13--2,15)), (2,0--2,15),
{ LetOrUseKeyword = (2,0--2,3)
InKeyword = Some (2,10--2,12) }), (2,0--2,15))],
InKeyword = Some (2,10--2,12)
EqualsRange = Some (2,6--2,7) }), (2,0--2,15))],
PreXmlDocEmpty, [], None, (2,0--2,15), { LeadingKeyword = None })],
(true, true), { ConditionalDirectives = []
WarnDirectives = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ ImplFile
EqualsRange = Some (3,6--3,7) })],
Const (Unit, (4,0--4,2)), (3,0--4,2),
{ LetOrUseKeyword = (3,0--3,3)
InKeyword = None }), (2,0--4,2)), (2,0--4,2))],
InKeyword = None
EqualsRange = Some (3,6--3,7) }), (2,0--4,2)), (2,0--4,2))],
PreXmlDocEmpty, [], None, (2,0--5,0), { LeadingKeyword = None })],
(true, true), { ConditionalDirectives = []
WarnDirectives = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ ImplFile
([e1; Value], [(4,10--4,11)], [None; None]), None,
(4,8--4,16))], [(4,6--4,7)], (4,0--4,16)),
(3,0--4,16), { LetOrUseKeyword = (3,0--3,3)
InKeyword = None }), (2,0--4,16)),
InKeyword = None
EqualsRange = Some (3,7--3,8) }), (2,0--4,16)),
(2,0--4,16))], PreXmlDocEmpty, [], None, (2,0--5,0),
{ LeadingKeyword = None })], (true, true),
{ ConditionalDirectives = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ ImplFile
EqualsRange = Some (4,10--4,11) })],
Const (Unit, (5,4--5,6)), (3,4--5,6),
{ LetOrUseKeyword = (3,4--3,11)
InKeyword = Some (4,15--4,17) }), (2,0--5,6)), (2,0--5,6))],
PreXmlDocEmpty, [], None, (2,0--6,0), { LeadingKeyword = None })],
(true, true), { ConditionalDirectives = []
WarnDirectives = []
CodeComments = [] }, set []))
InKeyword = Some (4,15--4,17)
EqualsRange = Some (3,14--3,15) }), (2,0--5,6)),
(2,0--5,6))], PreXmlDocEmpty, [], None, (2,0--6,0),
{ LeadingKeyword = None })], (true, true),
{ ConditionalDirectives = []
WarnDirectives = []
CodeComments = [] }, set []))
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ ImplFile
EqualsRange = Some (5,6--5,7) })],
ArbitraryAfterError ("seqExpr", (5,10--5,10)), (5,0--5,10),
{ LetOrUseKeyword = (5,0--5,3)
InKeyword = None }), [], (3,0--5,10), Yes (3,0--3,3),
Yes (5,10--5,10), { TryKeyword = (3,0--3,3)
TryToWithRange = (3,0--5,10)
WithKeyword = (5,10--5,10)
WithToEndRange = (3,0--5,10) }),
(3,0--5,10))],
InKeyword = None
EqualsRange = Some (5,6--5,7) }), [], (3,0--5,10),
Yes (3,0--3,3), Yes (5,10--5,10),
{ TryKeyword = (3,0--3,3)
TryToWithRange = (3,0--5,10)
WithKeyword = (5,10--5,10)
WithToEndRange = (3,0--5,10) }), (3,0--5,10))],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None,
(1,0--5,10), { LeadingKeyword = Module (1,0--1,6) })], (true, true),
{ ConditionalDirectives = []
Expand Down
12 changes: 7 additions & 5 deletions tests/service/data/SyntaxTree/LeadingKeyword/UseKeyword.fs.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ ImplFile
EqualsRange = Some (3,10--3,11) })],
Const (Unit, (4,4--4,6)), (3,4--4,6),
{ LetOrUseKeyword = (3,4--3,7)
InKeyword = None }), (2,0--4,6)), (2,0--4,6))],
PreXmlDocEmpty, [], None, (2,0--5,0), { LeadingKeyword = None })],
(true, true), { ConditionalDirectives = []
WarnDirectives = []
CodeComments = [] }, set []))
InKeyword = None
EqualsRange = Some (3,10--3,11) }), (2,0--4,6)),
(2,0--4,6))], PreXmlDocEmpty, [], None, (2,0--5,0),
{ LeadingKeyword = None })], (true, true),
{ ConditionalDirectives = []
WarnDirectives = []
CodeComments = [] }, set []))
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ ImplFile
EqualsRange = Some (3,14--3,15) })],
Const (Unit, (4,4--4,6)), (3,4--4,6),
{ LetOrUseKeyword = (3,4--3,11)
InKeyword = None }), (2,0--4,6)), (2,0--4,6))],
PreXmlDocEmpty, [], None, (2,0--5,0), { LeadingKeyword = None })],
(true, true), { ConditionalDirectives = []
WarnDirectives = []
CodeComments = [] }, set []))
InKeyword = None
EqualsRange = Some (3,14--3,15) }), (2,0--4,6)),
(2,0--4,6))], PreXmlDocEmpty, [], None, (2,0--5,0),
{ LeadingKeyword = None })], (true, true),
{ ConditionalDirectives = []
WarnDirectives = []
CodeComments = [] }, set []))
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ ImplFile
App
(NonAtomic, false, Ident Some, Ident content, (4,4--4,16)),
(3,4--4,16), { LetOrUseKeyword = (3,4--3,7)
InKeyword = None }),
InKeyword = None
EqualsRange = Some (3,16--3,17) }),
[SynMatchClause
(Named (SynIdent (ex, None), false, None, (6,2--6,4)), None,
Sequential
Expand Down
Loading
Loading