Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error reporting for MethodApplication #17556

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
145bf25
No matching overload error uses an accurate range
edgarfgp Aug 17, 2024
801de21
update baseline
edgarfgp Aug 17, 2024
2a9e6b2
Update ComputeItemRange
edgarfgp Aug 17, 2024
40a78bc
Update tests
edgarfgp Aug 17, 2024
a2b76be
Merge branch 'main' into fix-14844
edgarfgp Aug 20, 2024
d427c26
Merge branch 'main' into fix-14844
edgarfgp Aug 20, 2024
6872890
trying to find an accurate range
edgarfgp Aug 20, 2024
692a8e2
Merge branch 'fix-14844' of github.com:edgarfgp/fsharp into fix-14844
edgarfgp Aug 20, 2024
4c388b4
update tests
edgarfgp Aug 20, 2024
7cc2c2a
update tests
edgarfgp Aug 20, 2024
42e65a8
Merge branch 'fix-14844' of github.com:edgarfgp/fsharp into fix-14844
edgarfgp Aug 20, 2024
e545018
Merge branch 'main' into fix-14844
edgarfgp Aug 20, 2024
9bfbb6c
Merge branch 'main' into fix-14844
edgarfgp Aug 26, 2024
04886de
Merge branch 'main' into fix-14844
edgarfgp Aug 27, 2024
01516a1
Merge branch 'main' into fix-14844
edgarfgp Aug 29, 2024
a666f8f
Merge branch 'main' into fix-14844
edgarfgp Sep 4, 2024
fa0e60f
Merge branch 'main' into fix-14844
edgarfgp Sep 6, 2024
6ac787f
Merge branch 'main' into fix-14844
edgarfgp Sep 25, 2024
660840b
Merge branch 'main' into fix-14844
edgarfgp Oct 9, 2024
551d6ab
update ranges
edgarfgp Oct 11, 2024
bd85bea
Merge branch 'main' into fix-14844
edgarfgp Oct 11, 2024
03bfd1f
update ranges
edgarfgp Oct 11, 2024
a8409cf
Merge branch 'main' into fix-14844
edgarfgp Oct 11, 2024
f167e41
more ragne updates
edgarfgp Oct 11, 2024
c8ef20c
Im tired of updating ranges
edgarfgp Oct 11, 2024
6cc3af6
mMethExpr
edgarfgp Oct 11, 2024
35e48c0
mItem
edgarfgp Oct 12, 2024
19e84e2
Update edit tests
edgarfgp Oct 12, 2024
de64890
more updates
edgarfgp Oct 12, 2024
df1c042
Merge branch 'main' into fix-14844
edgarfgp Oct 24, 2024
d49785a
test
edgarfgp Oct 24, 2024
682a16b
Merge branch 'main' into fix-14844
edgarfgp Nov 6, 2024
9db3968
Merge branch 'main' into fix-14844
edgarfgp Nov 20, 2024
5085f51
Update baselines
edgarfgp Nov 20, 2024
a270cda
Update baselines
edgarfgp Nov 20, 2024
3a98303
Update editor tests
edgarfgp Nov 24, 2024
016d8ea
Update tests
edgarfgp Nov 24, 2024
48e954e
Update baselines
edgarfgp Nov 25, 2024
4f89051
Merge branch 'main' into fix-14844
edgarfgp Nov 25, 2024
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 src/Compiler/Checking/Expressions/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10182,7 +10182,7 @@ and TcMethodApplication
CanonicalizePartialInferenceProblem cenv.css denv mItem
(unnamedCurriedCallerArgs |> List.collectSquared (fun callerArg -> freeInTypeLeftToRight g false callerArg.CallerArgumentType))

let result, errors = ResolveOverloadingForCall denv cenv.css mMethExpr methodName callerArgs ad postArgumentTypeCheckingCalledMethGroup true returnTy
let result, errors = ResolveOverloadingForCall denv cenv.css mItem methodName callerArgs ad postArgumentTypeCheckingCalledMethGroup true returnTy

match afterResolution, result with
| AfterResolution.DoNothing, _ -> ()
Expand Down
21 changes: 11 additions & 10 deletions src/Compiler/Checking/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4075,14 +4075,15 @@ let private ResolveExprDotLongIdent (ncenv: NameResolver) m ad nenv ty (id: Iden
| _ ->
ForceRaise adhocDotSearchAccessible

let ComputeItemRange wholem (lid: Ident list) rest =
match rest with
| [] -> wholem
| _ ->
let ids = List.truncate (max 0 (lid.Length - rest.Length)) lid
match ids with
| [] -> wholem
| _ -> rangeOfLid ids
let ComputeItemRange wholem (lid: Ident list) =
if List.isEmpty lid then
wholem
else
lid
|> List.tryLast
|> Option.map (fun id -> id.idRange)
|> Option.defaultValue wholem


/// Filters method groups that will be sent to Visual Studio IntelliSense
/// to include only static/instance members
Expand Down Expand Up @@ -4130,7 +4131,7 @@ let ResolveLongIdentAsExprAndComputeRange (sink: TcResultsSink) (ncenv: NameReso
match ResolveExprLongIdent sink ncenv wholem ad nenv typeNameResInfo lid maybeAppliedArgExpr with
| Exception e -> Exception e
| Result (tinstEnclosing, item1, rest) ->
let itemRange = ComputeItemRange wholem lid rest
let itemRange = ComputeItemRange wholem lid

let item = FilterMethodGroups ncenv itemRange item1 true

Expand Down Expand Up @@ -4200,7 +4201,7 @@ let ResolveExprDotLongIdentAndComputeRange (sink: TcResultsSink) (ncenv: NameRes
| id :: rest ->
ResolveExprDotLongIdent ncenv wholem ad nenv ty id rest typeNameResInfo findFlag maybeAppliedArgExpr
| _ -> error(InternalError("ResolveExprDotLongIdentAndComputeRange", wholem))
let itemRange = ComputeItemRange wholem lid rest
let itemRange = ComputeItemRange wholem lid
resInfo, item, rest, itemRange

// "true" resolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ module AccessibilityAnnotations_Basic =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 1094, Line 18, Col 17, Line 18, Col 41, "The value 'somePrivateField' is not accessible from this code location")
(Error 1094, Line 19, Col 17, Line 19, Col 42, "The value 'somePrivateMethod' is not accessible from this code location")
(Error 491, Line 23, Col 17, Line 23, Col 34, "The member or object constructor 'PrivateMethod' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 1094, Line 18, Col 25, Line 18, Col 41, "The value 'somePrivateField' is not accessible from this code location")
(Error 1094, Line 19, Col 25, Line 19, Col 42, "The value 'somePrivateMethod' is not accessible from this code location")
(Error 491, Line 23, Col 19, Line 23, Col 34, "The member or object constructor 'PrivateMethod' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
]

//SOURCE=E_privateThingsInaccessible02.fs SCFLAGS="--test:ErrorRanges" # E_privateThingsInaccessible02.fs
Expand All @@ -70,11 +70,11 @@ module AccessibilityAnnotations_Basic =
|> shouldFail
|> withDiagnostics [
(Error 1092, Line 26, Col 19, Line 26, Col 32, "The type 'PrivateModule' is not accessible from this code location")
(Error 1094, Line 26, Col 17, Line 26, Col 34, "The value 'x' is not accessible from this code location")
(Error 1094, Line 26, Col 33, Line 26, Col 34, "The value 'x' is not accessible from this code location")
(Error 1092, Line 27, Col 19, Line 27, Col 32, "The type 'PrivateModule' is not accessible from this code location")
(Error 1094, Line 27, Col 17, Line 27, Col 34, "The value 'f' is not accessible from this code location")
(Error 1094, Line 29, Col 17, Line 29, Col 20, "The value 'y' is not accessible from this code location")
(Error 1094, Line 30, Col 17, Line 30, Col 20, "The value 'g' is not accessible from this code location")
(Error 1094, Line 27, Col 33, Line 27, Col 34, "The value 'f' is not accessible from this code location")
(Error 1094, Line 29, Col 19, Line 29, Col 20, "The value 'y' is not accessible from this code location")
(Error 1094, Line 30, Col 19, Line 30, Col 20, "The value 'g' is not accessible from this code location")
]

//SOURCE=E_privateThingsInaccessible03.fs SCFLAGS="--test:ErrorRanges" # E_privateThingsInaccessible03.fs
Expand All @@ -85,7 +85,7 @@ module AccessibilityAnnotations_Basic =
|> shouldFail
|> withDiagnostics [
(Error 1092, Line 11, Col 15, Line 11, Col 28, "The type 'PrivateModule' is not accessible from this code location")
(Error 1094, Line 11, Col 13, Line 11, Col 30, "The value 'x' is not accessible from this code location")
(Error 1094, Line 11, Col 29, Line 11, Col 30, "The value 'x' is not accessible from this code location")
(Error 39, Line 15, Col 13, Line 15, Col 26, "The value, namespace, type or module 'PrivateModule' is not defined.")
]

Expand All @@ -109,7 +109,7 @@ module AccessibilityAnnotations_Basic =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 1096, Line 11, Col 9, Line 11, Col 24, "The record, struct or class field 'foo' is not accessible from this code location")
(Error 1096, Line 11, Col 21, Line 11, Col 24, "The record, struct or class field 'foo' is not accessible from this code location")
]

//SOURCE=E_PrivateImplicitCtor01.fs SCFLAGS="--test:ErrorRanges" # E_PrivateImplicitCtor01.fs
Expand All @@ -129,7 +129,7 @@ module AccessibilityAnnotations_Basic =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 629, Line 11, Col 24, Line 11, Col 41, "Method 'MemberwiseClone' is not accessible from this code location")
(Error 629, Line 11, Col 26, Line 11, Col 41, "Method 'MemberwiseClone' is not accessible from this code location")
]

//SOURCE=E_MoreAccessibleBaseClass01.fs # E_MoreAccessibleBaseClass01.fs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module AccessibilityAnnotations_OnTypeMembers =
|> shouldFail
|> withDiagnostics [
(Warning 1178, Line 9, Col 10, Line 9, Col 17, "The struct, record or union type 'SpecSet' is not structurally comparable because the type 'SpecMulti' does not satisfy the 'comparison' constraint. Consider adding the 'NoComparison' attribute to the type 'SpecSet' to clarify that the type is not comparable")
(Error 491, Line 14, Col 13, Line 14, Col 28, "The member or object constructor 'Impl' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 491, Line 14, Col 21, Line 14, Col 28, "The member or object constructor 'Impl' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
]

// SOURCE=E_OnProperty01.fs # E_OnProperty01.fs
Expand All @@ -62,18 +62,18 @@ module AccessibilityAnnotations_OnTypeMembers =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 491, Line 42, Col 1, Line 42, Col 6, "The member or object constructor 'Foo' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 491, Line 42, Col 9, Line 42, Col 16, "The member or object constructor 'test1' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 491, Line 42, Col 19, Line 42, Col 26, "The member or object constructor 'test2' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 491, Line 42, Col 29, Line 42, Col 36, "The member or object constructor 'test5' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 491, Line 42, Col 40, Line 42, Col 47, "The member or object constructor 'test6' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 807, Line 42, Col 60, Line 42, Col 67, "Property 'test8' is not readable")
(Error 491, Line 42, Col 3, Line 42, Col 6, "The member or object constructor 'Foo' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 491, Line 42, Col 11, Line 42, Col 16, "The member or object constructor 'test1' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 491, Line 42, Col 21, Line 42, Col 26, "The member or object constructor 'test2' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 491, Line 42, Col 31, Line 42, Col 36, "The member or object constructor 'test5' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 491, Line 42, Col 42, Line 42, Col 47, "The member or object constructor 'test6' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 807, Line 42, Col 62, Line 42, Col 67, "Property 'test8' is not readable")
(Error 491, Line 43, Col 1, Line 43, Col 13, "The member or object constructor 'test3' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 491, Line 44, Col 1, Line 44, Col 13, "The member or object constructor 'test4' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 491, Line 45, Col 1, Line 45, Col 13, "The member or object constructor 'test5' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 491, Line 46, Col 1, Line 46, Col 13, "The member or object constructor 'test6' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
(Error 810, Line 47, Col 1, Line 47, Col 8, "Property 'test7' cannot be set")
(Error 257, Line 47, Col 1, Line 47, Col 8, "Invalid mutation of a constant expression. Consider copying the expression to a mutable local, e.g. 'let mutable x = ...'.")
(Error 810, Line 47, Col 3, Line 47, Col 8, "Property 'test7' cannot be set")
(Error 257, Line 47, Col 3, Line 47, Col 8, "Invalid mutation of a constant expression. Consider copying the expression to a mutable local, e.g. 'let mutable x = ...'.")
]

// SOURCE=E_OnProperty02.fs SCFLAGS="--test:ErrorRanges" # E_OnProperty02.fs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 685, Line 14, Col 1, Line 14, Col 6, "The generic function 'Foo' must be given explicit type argument(s)")
(Error 685, Line 26, Col 1, Line 26, Col 6, "The generic function 'Foo' must be given explicit type argument(s)")
(Error 685, Line 28, Col 1, Line 28, Col 6, "The generic function 'Foo' must be given explicit type argument(s)")
(Error 685, Line 14, Col 3, Line 14, Col 6, "The generic function 'Foo' must be given explicit type argument(s)")
(Error 685, Line 26, Col 3, Line 26, Col 6, "The generic function 'Foo' must be given explicit type argument(s)")
(Error 685, Line 28, Col 3, Line 28, Col 6, "The generic function 'Foo' must be given explicit type argument(s)")
]

// SOURCE=E_RequiresExplicitTypeArguments02.fs SCFLAGS="--test:ErrorRanges" # E_RequiresExplicitTypeArguments02.fs
Expand All @@ -281,7 +281,7 @@ module CustomAttributes_AttributeUsage =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 685, Line 20, Col 5, Line 20, Col 10, "The generic function 'Foo' must be given explicit type argument(s)")
(Error 685, Line 20, Col 7, Line 20, Col 10, "The generic function 'Foo' must be given explicit type argument(s)")
]

// SOURCE=E_WithBitwiseOr01.fsx SCFLAGS="--test:ErrorRanges -a" # E_WithBitwiseOr01.fsx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ let main _ =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 1201, Line 15, Col 59, Line 15, Col 101, "Cannot call an abstract base member: 'Write'")
(Error 1201, Line 15, Col 64, Line 15, Col 101, "Cannot call an abstract base member: 'Write'")
]


Expand Down Expand Up @@ -178,5 +178,5 @@ let main _ =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 1201, Line 13, Col 59, Line 13, Col 101, "Cannot call an abstract base member: 'Write'")
(Error 1201, Line 13, Col 64, Line 13, Col 101, "Cannot call an abstract base member: 'Write'")
]
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ module MemberDefinitions_MethodsAndProperties =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 493, Line 10, Col 14, Line 10, Col 30, "StaticMethod is not an instance method")
(Error 493, Line 10, Col 16, Line 10, Col 30, "StaticMethod is not an instance method")
]

// SOURCE=genericGenericClass.fs # genericGenericClass.fs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module MemberDefinitions_NamedArguments =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 35, Line 16, Col 1, Line 16, Col 35, "This construct is deprecated: The unnamed arguments do not form a prefix of the arguments of the method called")
(Error 35, Line 16, Col 3, Line 16, Col 35, "This construct is deprecated: The unnamed arguments do not form a prefix of the arguments of the method called")
]

// SOURCE=E_NonNamedAfterNamed.fs # E_NonNamedAfterNamed.fs
Expand All @@ -58,8 +58,8 @@ module MemberDefinitions_NamedArguments =
|> shouldFail
|> withDiagnostics [
(Error 941, Line 13, Col 28, Line 13, Col 38, "Accessibility modifiers are not permitted on overrides or interface implementations")
(Error 497, Line 18, Col 1, Line 18, Col 32, "The member or object constructor 'NamedMeth1' requires 1 additional argument(s). The required signature is 'abstract IFoo.NamedMeth1: arg1: int * arg2: int * arg3: int * arg4: int -> float'.")
(Error 500, Line 19, Col 1, Line 19, Col 43, "The member or object constructor 'NamedMeth1' requires 4 argument(s) but is here given 2 unnamed and 3 named argument(s). The required signature is 'abstract IFoo.NamedMeth1: arg1: int * arg2: int * arg3: int * arg4: int -> float'.")
(Error 497, Line 18, Col 3, Line 18, Col 32, "The member or object constructor 'NamedMeth1' requires 1 additional argument(s). The required signature is 'abstract IFoo.NamedMeth1: arg1: int * arg2: int * arg3: int * arg4: int -> float'.")
(Error 500, Line 19, Col 3, Line 19, Col 43, "The member or object constructor 'NamedMeth1' requires 4 argument(s) but is here given 2 unnamed and 3 named argument(s). The required signature is 'abstract IFoo.NamedMeth1: arg1: int * arg2: int * arg3: int * arg4: int -> float'.")
]

// SOURCE=E_ReusedParam.fs # E_ReusedParam.fs
Expand All @@ -82,7 +82,7 @@ module MemberDefinitions_NamedArguments =
|> withDiagnostics [
(Error 39, Line 8, Col 47, Line 8, Col 51, "The value or constructor 'arg1' is not defined.")
(Error 39, Line 8, Col 54, Line 8, Col 58, "The value or constructor 'arg2' is not defined.")
(Error 3, Line 12, Col 1, Line 12, Col 8, "This value is not a function and cannot be applied.")
(Error 3, Line 12, Col 3, Line 12, Col 8, "This value is not a function and cannot be applied.")
]

// SOURCE=genericNamedParams.fs # genericNamedParams.fs
Expand Down
Loading
Loading