Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/9.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* C# protected property can be assigned in F# inherit constructor call. ([Issue #13299](https://github.com/dotnet/fsharp/issues/13299), [PR #17391](https://github.com/dotnet/fsharp/pull/17391))
* MethodAccessException on equality comparison of a record with private fields. ([Issue #17447](https://github.com/dotnet/fsharp/issues/17447), [PR #17391](https://github.com/dotnet/fsharp/pull/17467))
* Compiler fails to recognise namespace in FQN with enabled GraphBasedChecking. ([Issue #17508](https://github.com/dotnet/fsharp/issues/17508), [PR #17510](https://github.com/dotnet/fsharp/pull/17510))
* Fix missing message for type error (FS0001). ([Issue #17373](https://github.com/dotnet/fsharp/issues/17373), [PR #17516](https://github.com/dotnet/fsharp/pull/17516))

### Added

Expand Down
7 changes: 6 additions & 1 deletion src/Compiler/Driver/CompilerDiagnostics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ type Exception with

| ErrorFromAddingTypeEquation(error = ConstraintSolverError _ as e) -> e.Output(os, suggestNames)

| ErrorFromAddingTypeEquation(_g, denv, ty1, ty2, ConstraintSolverTupleDiffLengths(_, contextInfo, tl1, tl2, _, _), m) ->
| ErrorFromAddingTypeEquation(_g, denv, ty1, ty2, ConstraintSolverTupleDiffLengths(_, contextInfo, tl1, tl2, m1, m2), m) ->
let ty1, ty2, tpcs = NicePrint.minimalStringsOfTwoTypes denv ty1 ty2
let messageArgs = tl1.Length, ty1, tl2.Length, ty2

Expand All @@ -826,6 +826,11 @@ type Exception with
else
os.AppendString(FSComp.SR.listElementHasWrongTypeTuple messageArgs)
| _ -> os.AppendString(ErrorFromAddingTypeEquationTuplesE().Format tl1.Length ty1 tl2.Length ty2 tpcs)
else
os.AppendString(ConstraintSolverTupleDiffLengthsE().Format tl1.Length tl2.Length)

if m1.StartLine <> m2.StartLine then
os.AppendString(SeeAlsoE().Format(stringOfRange m1))
Comment on lines +832 to +833
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edgarfgp Could you add some cases covering this check, please?


| ErrorFromAddingTypeEquation(g, denv, ty1, ty2, e, _) ->
if not (typeEquiv g ty1 ty2) then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,22 @@ let f4 =
(Error 1, Line 28, Col 9, Line 28, Col 12, "This expression was expected to have type\n 'int64' \nbut here has type\n 'float' ")
]

[<Fact>]
let ``Error when tuples have differing lengths and we do not know the types.``() =
Fsx """
let foo items =
for (a,b,c) in items do
printfn "%A" (a, c)

[<EntryPoint>]
let main args =
foo ({1..10} |> Seq.pairwise)
0
"""
|> asExe
|> typecheck
|> shouldFail
|> withDiagnostics [
(Error 1, Line 8, Col 21, Line 8, Col 33, "The tuples have differing lengths of 3 and 2")
]