Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
9d3917a
Support CallerArgumentExpression
ijklam Jun 11, 2024
b698a3b
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Aug 11, 2024
dec3d3e
fix for fsi
ijklam Aug 11, 2024
e5d7763
revert unnecessary changes
ijklam Aug 11, 2024
5119bb6
Read and store file content before compilation
ijklam Aug 11, 2024
c914672
Change test; Add release note
ijklam Aug 11, 2024
5fe3495
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Aug 11, 2024
536cf34
Add tests
ijklam Aug 11, 2024
b270e16
Merge branch 'SupportCallerArgumentExpression' of https://github.com/…
ijklam Aug 11, 2024
3fc4642
fix build; format
ijklam Aug 11, 2024
550daa4
Support `#line`
ijklam Aug 15, 2024
5cecb20
format
ijklam Aug 15, 2024
1b6cd56
support callee side optional arg
ijklam Aug 16, 2024
08d958b
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Aug 16, 2024
68f2f61
format code
ijklam Aug 16, 2024
ec3b97f
Merge branch 'SupportCallerArgumentExpression' of https://github.com/…
ijklam Aug 16, 2024
7e93270
fix build
ijklam Aug 16, 2024
5790db9
fix test
ijklam Aug 16, 2024
46c4d46
try fix tests
ijklam Aug 25, 2024
8d792fa
fix build
ijklam Aug 25, 2024
65a4acc
test
ijklam Aug 25, 2024
1bdae47
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Sep 26, 2024
9e46116
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Feb 3, 2025
f379b7f
simplify code
ijklam Feb 3, 2025
843c71a
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Feb 3, 2025
6d1a30d
simplify code; fix test
ijklam Feb 4, 2025
5f499a5
fix range
ijklam Feb 4, 2025
470b993
fix tests
ijklam Feb 4, 2025
477ed6e
fix tests
ijklam Feb 4, 2025
6fb6548
fix
ijklam Feb 4, 2025
c8ca45b
test
ijklam Feb 4, 2025
b5f22fb
test
ijklam Feb 4, 2025
271985b
test
ijklam Feb 4, 2025
31e7bb2
fix tests
ijklam Feb 26, 2025
d47ee7e
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Feb 26, 2025
424b83c
update baselines
ijklam Feb 26, 2025
77697cd
fix tests
ijklam Feb 26, 2025
1e43eff
test
ijklam Feb 26, 2025
2d38b2a
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Mar 11, 2025
52a0fc0
fix named arguments didn't trigger the feature
ijklam Mar 11, 2025
24a9494
baseline
ijklam Mar 11, 2025
935af15
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Mar 11, 2025
31125f5
add new tests; improve err msg
ijklam Mar 13, 2025
49c46b1
adjust code; add and update tests
ijklam Mar 13, 2025
983f180
baseline
ijklam Mar 13, 2025
cf2085b
fix test
ijklam Mar 14, 2025
52a4d53
fmt
ijklam Mar 14, 2025
6e6dd39
Support for user defined CallerArgumentExpressionAttribute
ijklam Mar 15, 2025
9c5d917
replace the way get substring text
ijklam Mar 15, 2025
795c64a
test
ijklam Mar 15, 2025
98d8708
fix build
ijklam Mar 15, 2025
d68a6f7
fix test
ijklam Mar 15, 2025
9ac37e6
test
ijklam Mar 15, 2025
2cfba8d
Merge branch 'main' into SupportCallerArgumentExpression
psfinaki Mar 17, 2025
262ed24
revert the modify to `range`
ijklam Mar 17, 2025
9c24123
fix test and add new test
ijklam Mar 17, 2025
081a36b
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Mar 17, 2025
1999506
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Mar 20, 2025
2e7121d
add a new test
ijklam Mar 20, 2025
fb8a3d0
add test
ijklam Mar 20, 2025
70f5630
change the position to get code file content
ijklam Mar 21, 2025
1cc4395
refractor
ijklam Mar 21, 2025
3c1deb4
new test
ijklam Mar 21, 2025
a5a4b8b
refactor
ijklam Mar 25, 2025
5cba8ca
fmt
ijklam Mar 25, 2025
0b02f01
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Mar 25, 2025
1258816
baseline; fix test
ijklam Mar 25, 2025
95a4930
fix test
ijklam Mar 25, 2025
c3baed5
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Mar 25, 2025
5e1e27c
try fix cannot determine in C# method with non BCL attr
ijklam Mar 25, 2025
199d4b5
refactor
ijklam Mar 26, 2025
5e3e596
fix test
ijklam Mar 26, 2025
607f2d1
ilverify
ijklam Mar 26, 2025
1194359
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Mar 26, 2025
f792bfa
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Apr 14, 2025
5aff4b2
fix build
ijklam Apr 14, 2025
173d748
Change the approach to implement the feature
ijklam Apr 19, 2025
499bb33
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Apr 19, 2025
a215efa
change the way to pass the source text in
ijklam Apr 19, 2025
10b37d1
ilverify
ijklam Apr 19, 2025
f0da587
fmt
ijklam Apr 19, 2025
6d76a8e
make `cenv.Create(..., sourceText)` param not optional
ijklam Apr 22, 2025
be64605
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Apr 28, 2025
874755a
fix no clear action; add OptionalArgument + Struct test
ijklam Apr 28, 2025
0ccbdf9
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Apr 28, 2025
5005a74
revert clear action
ijklam Apr 28, 2025
ec351c5
add a big file test
ijklam Apr 29, 2025
5b51706
Merge branch 'main' into SupportCallerArgumentExpression
ijklam May 5, 2025
09d200e
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam May 15, 2025
ca912b5
fix build; fantomas
ijklam May 15, 2025
bf3841e
make the feature compatible with #line
ijklam May 15, 2025
462fd40
ilverify
ijklam May 15, 2025
d703b20
disable fGetOriginalRange
ijklam May 15, 2025
5da8999
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Aug 7, 2025
ffa4420
fix build
ijklam Aug 7, 2025
4f494c1
fix and enable test
ijklam Aug 7, 2025
89e1ec6
fix test
ijklam Aug 12, 2025
12bdce8
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Aug 12, 2025
55f6c46
add a new test
ijklam Aug 12, 2025
5526611
assert enhancement
ijklam Aug 13, 2025
f7d9c6d
update test
ijklam Aug 13, 2025
39c6a10
add a test
ijklam Aug 27, 2025
3b89702
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Aug 27, 2025
76bb2be
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Sep 4, 2025
4724740
add a info warning
ijklam Sep 5, 2025
1c521d6
add missing cases in caller info attributes check
ijklam Sep 5, 2025
9722b9e
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Sep 5, 2025
259f753
fix build
ijklam Sep 5, 2025
8aa12a2
fix test
ijklam Sep 5, 2025
c2400bb
Merge remote-tracking branch 'upstream/main' into SupportCallerArgume…
ijklam Sep 18, 2025
0f5fbec
Merge branch 'main' into SupportCallerArgumentExpression
ijklam Sep 30, 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: 2 additions & 0 deletions docs/release-notes/.FSharp.Compiler.Service/10.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Diagnostics: add extended data for 'No constructors' error ([PR #18863](https://github.com/dotnet/fsharp/pull/18863))
* FSharpType.Format: support top-level prefix generic types style. ([PR #18897](https://github.com/dotnet/fsharp/pull/18897))
* FCS: allow getting captured types ([PR $18878](https://github.com/dotnet/fsharp/pull/18878))
* Support `CallerArgumentExpression` ([Language Suggestion #966](https://github.com/fsharp/fslang-suggestions/issues/966), [PR #17519](https://github.com/dotnet/fsharp/pull/17519))

### Fixed

Expand Down Expand Up @@ -42,6 +43,7 @@
* Parser: Capture named fields block separators. ([PR #18857](https://github.com/dotnet/fsharp/pull/18857))
* Type checker: use inner expr range in upcast constraints errors ([PR #18850](https://github.com/dotnet/fsharp/pull/18850))
* Import `IEnumerable` as `seq`. ([PR #18865](https://github.com/dotnet/fsharp/pull/18865))
* `assert` keyword enhancement ([Issue #18489](https://github.com/dotnet/fsharp/issues/18489), [PR #17519](https://github.com/dotnet/fsharp/pull/17519))

### Breaking Changes

Expand Down
1 change: 1 addition & 0 deletions docs/release-notes/.Language/preview.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Allow `let!`, `use!`, `and!` type annotations without requiring parentheses (([PR #18508](https://github.com/dotnet/fsharp/pull/18508) and [PR #18682](https://github.com/dotnet/fsharp/pull/18682)))
* Exception names are now validated for illegal characters using the same mechanism as types/modules/namespaces ([Issue #18763](https://github.com/dotnet/fsharp/issues/18763))
* Support tail calls in computation expressions ([PR #18804](https://github.com/dotnet/fsharp/pull/18804))
* Support `CallerArgumentExpression` ([Language Suggestion #966](https://github.com/fsharp/fslang-suggestions/issues/966), [PR #17519](https://github.com/dotnet/fsharp/pull/17519))

### Fixed

Expand Down
6 changes: 5 additions & 1 deletion src/Compiler/Checking/CheckBasics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ type TcFileState =

// forward call
TcComputationExpression: TcFileState -> TcEnv -> OverallTy -> UnscopedTyparEnv -> range * Expr * TType * SynExpr -> Expr * UnscopedTyparEnv

SourceText: ISourceText option
}

/// Create a new compilation environment
Expand All @@ -344,7 +346,8 @@ type TcFileState =
tcSimplePats,
tcSequenceExpressionEntry,
tcArrayOrListSequenceExpression,
tcComputationExpression) =
tcComputationExpression,
sourceText: ISourceText option) =

let niceNameGen = NiceNameGenerator()
let infoReader = InfoReader(g, amap)
Expand Down Expand Up @@ -376,6 +379,7 @@ type TcFileState =
TcSequenceExpressionEntry = tcSequenceExpressionEntry
TcArrayOrListComputedExpression = tcArrayOrListSequenceExpression
TcComputationExpression = tcComputationExpression
SourceText = sourceText
}

override _.ToString() = "<cenv>"
6 changes: 5 additions & 1 deletion src/Compiler/Checking/CheckBasics.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ type TcFileState =
-> UnscopedTyparEnv
-> range * Expr * TType * SynExpr
-> Expr * UnscopedTyparEnv

/// The impl file content. Used to support `CallerArgumentExpression` feature.
SourceText: ISourceText option
}

static member Create:
Expand Down Expand Up @@ -356,5 +359,6 @@ type TcFileState =
-> OverallTy
-> UnscopedTyparEnv
-> range * Expr * TType * SynExpr
-> Expr * UnscopedTyparEnv) ->
-> Expr * UnscopedTyparEnv) *
sourceText: ISourceText option ->
TcFileState
9 changes: 6 additions & 3 deletions src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5766,7 +5766,8 @@ let CheckOneImplFile
env,
rootSigOpt: ModuleOrNamespaceType option,
synImplFile,
diagnosticOptions) =
diagnosticOptions,
sourceText: ISourceText option) =

let (ParsedImplFileInput (fileName, isScript, qualNameOfFile, _, implFileFrags, isLastCompiland, _, _)) = synImplFile
let infoReader = InfoReader(g, amap)
Expand All @@ -5789,7 +5790,8 @@ let CheckOneImplFile
tcSimplePats=TcSimplePats,
tcSequenceExpressionEntry=TcSequenceExpressionEntry,
tcArrayOrListSequenceExpression=TcArrayOrListComputedExpression,
tcComputationExpression=TcComputationExpression)
tcComputationExpression=TcComputationExpression,
sourceText=sourceText)

let envinner, moduleTyAcc = MakeInitialEnv env

Expand Down Expand Up @@ -5934,7 +5936,8 @@ let CheckOneSigFile (g, amap, thisCcu, checkForErrors, conditionalDefines, tcSin
tcSimplePats=TcSimplePats,
tcSequenceExpressionEntry=TcSequenceExpressionEntry,
tcArrayOrListSequenceExpression=TcArrayOrListComputedExpression,
tcComputationExpression=TcComputationExpression)
tcComputationExpression=TcComputationExpression,
sourceText=None)

let envinner, moduleTyAcc = MakeInitialEnv tcEnv
let m = sigFile.QualifiedName.Range
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/Checking/CheckDeclarations.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ val CheckOneImplFile:
TcEnv *
ModuleOrNamespaceType option *
ParsedImplFileInput *
FSharpDiagnosticOptions ->
FSharpDiagnosticOptions *
ISourceText option ->
Cancellable<TopAttribs * CheckedImplFile * TcEnv * bool>

val CheckOneSigFile:
Expand Down
30 changes: 27 additions & 3 deletions src/Compiler/Checking/Expressions/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7727,9 +7727,23 @@ and TcConstExpr cenv (overallTy: OverallTy) env m tpenv c =
// Check an 'assert x' expression.
and TcAssertExpr cenv overallTy env (m: range) tpenv x =
let synm = m.MakeSynthetic() // Mark as synthetic so the language service won't pick it up.

// wrap an extra parentheses so 'assert(x=1) isn't considered a named argument to a method call
let arg1Expr = SynExpr.Paren (x, range0, None, synm)

let argExpr =
match cenv.SourceText with
| Some sourceText when cenv.g.langVersion.SupportsFeature LanguageFeature.SupportCallerArgumentExpression ->
let mArgExpr = x.Range.MakeSynthetic()
let code = sourceText.GetSubTextFromRange mArgExpr
if System.String.IsNullOrEmpty code then arg1Expr
else
let arg2Expr = SynExpr.Const (SynConst.String (code, SynStringKind.Regular, mArgExpr), mArgExpr)
SynExpr.Tuple(false, [arg1Expr; arg2Expr], [], mArgExpr)
| _ -> arg1Expr

let callDiagnosticsExpr = SynExpr.App (ExprAtomicFlag.Atomic, false, mkSynLidGet synm ["System";"Diagnostics";"Debug"] "Assert",
// wrap an extra parentheses so 'assert(x=1) isn't considered a named argument to a method call
SynExpr.Paren (x, range0, None, synm), synm)
argExpr, synm)

TcExpr cenv overallTy env tpenv callDiagnosticsExpr

Expand Down Expand Up @@ -10309,8 +10323,18 @@ and TcMethodApplication
/// STEP 5. Build the argument list. Adjust for optional arguments, byref arguments and coercions.

let objArgPreBinder, objArgs, allArgsPreBinders, allArgs, allArgsCoerced, optArgPreBinder, paramArrayPreBinders, outArgExprs, outArgTmpBinds =

// We apply CallerArgumentExpression to optional parameters only when the method call has syntactic arguments.
// Otherwise, we cannot get the range of the argument. The argument range will be the method name range.
// System.ArgumentException.ThrowIfNullOrEmpty(null) <-- Can get the argument text through its range
// (System.ArgumentException.ThrowIfNullOrEmpty) null <-- Cannot get the right text
// System.ArgumentException.ThrowIfNullOrEmpty <| null <-- Cannot get the right text
// null |> System.ArgumentException.ThrowIfNullOrEmpty <-- Cannot get the right text
// let f = System.ArgumentException.ThrowIfNullOrEmpty in f(null) <-- Cannot get the right text
let canApplyCallerArgumentExpression = curriedCallerArgsOpt.IsSome

let tcVal = LightweightTcValForUsingInBuildMethodCall g
AdjustCallerArgs tcVal TcFieldInit env.eCallerMemberName cenv.infoReader ad finalCalledMeth objArgs lambdaVars mItem mMethExpr
AdjustCallerArgs tcVal TcFieldInit cenv.infoReader ad finalCalledMeth objArgs lambdaVars mItem mMethExpr (env.eCallerMemberName, cenv.SourceText, canApplyCallerArgumentExpression)

// Record the resolution of the named argument for the Language Service
allArgs |> List.iter (fun assignedArg ->
Expand Down
Loading
Loading