Skip to content

Commit 4107011

Browse files
authored
Merge pull request #1286 from forki/wrongarity
Wrong number of args reported in error message
2 parents 047d472 + b00cda0 commit 4107011

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

src/fsharp/ConstraintSolver.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,8 +2064,7 @@ and ReportNoCandidatesError (csenv:ConstraintSolverEnv) (nUnnamedCallerArgs,nNam
20642064

20652065
// One or more accessible, all the same arity, none correct
20662066
| ((cmeth :: cmeths2),_),_,_,_,_ when not cmeth.HasCorrectArity && cmeths2 |> List.forall (fun cmeth2 -> cmeth.TotalNumUnnamedCalledArgs = cmeth2.TotalNumUnnamedCalledArgs) ->
2067-
ErrorD (Error (FSComp.SR.csMemberNotAccessible(methodName, (cmeth.ArgSets |> List.sumBy (fun x -> x.NumUnnamedCalledArgs)), methodName, cmeth.TotalNumUnnamedCalledArgs),m))
2068-
2067+
ErrorD (Error (FSComp.SR.csMemberNotAccessible(methodName, nUnnamedCallerArgs, methodName, cmeth.TotalNumUnnamedCalledArgs),m))
20692068
// Many methods, all with incorrect number of generic arguments
20702069
| _,_,_,([],(cmeth :: _)),_ ->
20712070
let msg = FSComp.SR.csIncorrectGenericInstantiation((ShowAccessDomain ad), methodName, cmeth.NumCallerTyArgs)

src/fsharp/FSComp.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ csCtorHasNoArgumentOrReturnProperty,"The object constructor '%s' has no argument
343343
500,csMemberSignatureMismatchArityNamed,"The member or object constructor '%s' requires %d argument(s) but is here given %d unnamed and %d named argument(s). The required signature is '%s'."
344344
501,csMemberSignatureMismatchArity,"The member or object constructor '%s' takes %d argument(s) but is here given %d. The required signature is '%s'."
345345
502,csMemberSignatureMismatchArityType,"The member or object constructor '%s' takes %d type argument(s) but is here given %d. The required signature is '%s'."
346-
503,csMemberNotAccessible,"The member or object constructor '%s' taking %d arguments are not accessible from this code location. All accessible versions of method '%s' take %d arguments."
346+
503,csMemberNotAccessible,"A member or object constructor '%s' taking %d arguments is not accessible from this code location. All accessible versions of method '%s' take %d arguments."
347347
504,csIncorrectGenericInstantiation,"Incorrect generic instantiation. No %s member named '%s' takes %d generic arguments."
348348
505,csMemberOverloadArityMismatch,"The member or object constructor '%s' does not take %d argument(s). An overload was found taking %d arguments."
349349
506,csNoMemberTakesTheseArguments,"No %s member or object constructor named '%s' takes %d arguments"

tests/fsharpqa/Source/Conformance/Expressions/SyntacticSugar/E_Slices01.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//<Expects id="FS0041" status="error" span="(24,9)">A unique overload for method 'GetSlice' could not be determined based on type information prior to this program point\. A type annotation may be needed\. Candidates: member Foo\.GetSlice : x1:float option \* x2:int option \* y:int -> unit, member Foo\.GetSlice : x1:int option \* x2:int option \* y:int -> unit</Expects>
88
//<Expects id="FS0041" status="error" span="(25,9)">A unique overload for method 'GetSlice' could not be determined based on type information prior to this program point\. A type annotation may be needed\. Candidates: member Foo\.GetSlice : x1:float option \* x2:int option \* y:int -> unit, member Foo\.GetSlice : x1:int option \* x2:int option \* y:int -> unit</Expects>
99
//<Expects id="FS0039" status="error" span="(26,9)">The field, constructor or member 'Item' is not defined</Expects>
10-
//<Expects id="FS0503" status="error" span="(27,9)">The member or object constructor 'GetSlice' taking 3 arguments are not accessible from this code location\. All accessible versions of method 'GetSlice' take 3 arguments\.</Expects>
11-
//<Expects id="FS0503" status="error" span="(28,9)">The member or object constructor 'GetSlice' taking 3 arguments are not accessible from this code location\. All accessible versions of method 'GetSlice' take 3 arguments\.</Expects>
10+
//<Expects id="FS0503" status="error" span="(27,9)">A member or object constructor 'GetSlice' taking 4 arguments is not accessible from this code location\. All accessible versions of method 'GetSlice' take 3 arguments\.</Expects>
11+
//<Expects id="FS0503" status="error" span="(28,9)">A member or object constructor 'GetSlice' taking 5 arguments is not accessible from this code location\. All accessible versions of method 'GetSlice' take 3 arguments\.</Expects>
1212

1313
type Foo<'a>() =
1414
member this.GetSlice(x : int, y1 : int option, y2 : int option) = ()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// #Warnings
2+
//<Expects status="Error" id="FS0503">A member or object constructor 'MyMember' taking 3</Expects>
3+
4+
type MyType() =
5+
static member MyMember(arg1, arg2:int ) = ()
6+
static member MyMember(arg1, arg2:byte) = ()
7+
8+
9+
MyType.MyMember("", 0, 0)
10+
11+
exit 0

tests/fsharpqa/Source/Warnings/env.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
SOURCE=InvalidRecord.fs # InvalidRecord.fs
66
SOURCE=CommaInRecCtor.fs # CommaInRecCtor.fs
77
SOURCE=ValidCommaInRecCtor.fs # ValidCommaInRecCtor.fs
8+
SOURCE=WrongArity.fs # WrongArity.fs
89
SOURCE=AccessOfTypeAbbreviation.fs # AccessOfTypeAbbreviation.fs
910
SOURCE=AccessOfTypeAbbreviation2.fs # AccessOfTypeAbbreviation2.fs
1011
SOURCE=AccessOfTypeAbbreviation3.fs # AccessOfTypeAbbreviation3.fs

0 commit comments

Comments
 (0)