From 2c3cfbf8732a5bf4a4cd9e31c5b9546d9b215874 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Sat, 24 Feb 2018 10:34:15 +0000 Subject: [PATCH] fix tuple warnings (#4389) * fix tuple warnings * fix tuple warnings * fix tuple warnings * fix tuple warnings --- src/fsharp/TypeChecker.fs | 2 +- tests/fsharp/typecheck/sigs/neg101.fs | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index dc3954c78..3a1fa009c 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -174,7 +174,7 @@ let MethInfoChecks g amap isInstance tyargsOpt objArgs ad m (minfo:MethInfo) = if not (IsTypeAndMethInfoAccessible amap m adOriginal ad minfo) then error (Error (FSComp.SR.tcMethodNotAccessible(minfo.LogicalName), m)) - if isAnyTupleTy g minfo.ApparentEnclosingType then + if isAnyTupleTy g minfo.ApparentEnclosingType && not minfo.IsExtensionMember && (minfo.LogicalName.StartsWith "get_Item" || minfo.LogicalName.StartsWith "get_Rest") then warning (Error (FSComp.SR.tcTupleMemberNotNormallyUsed(), m)) CheckMethInfoAttributes g m tyargsOpt minfo |> CommitOperationResult diff --git a/tests/fsharp/typecheck/sigs/neg101.fs b/tests/fsharp/typecheck/sigs/neg101.fs index 76785bd35..46e642d20 100644 --- a/tests/fsharp/typecheck/sigs/neg101.fs +++ b/tests/fsharp/typecheck/sigs/neg101.fs @@ -1,6 +1,6 @@ module M - +open System type MyRec = { Foo: string } let x: int = 1 @@ -47,4 +47,16 @@ let x1 = (1,2,3,4,5,6,7,8).Item7 ] let x2 = (1,2,3,4,5,6,7,8).Rest // gives a warning -let x3 = (1,2).Rest // gives an actual error \ No newline at end of file +let x3 = (1,2).Rest // gives an actual error +let x4 = (struct (1,2)).ToTuple() // no error or warning + +open System.Runtime.CompilerServices + +[] +type TupleEx() = + [] + static member inline Do((x,y): (int*string)) = () + +let x = 1, "2" + +x.Do() // no warning -- GitLab