提交 2c3cfbf8 编写于 作者: D Don Syme 提交者: Kevin Ransom (msft)

fix tuple warnings (#4389)

* fix tuple warnings

* fix tuple warnings

* fix tuple warnings

* fix tuple warnings
上级 71311430
......@@ -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
......
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
[<Extension>]
type TupleEx() =
[<Extension>]
static member inline Do((x,y): (int*string)) = ()
let x = 1, "2"
x.Do() // no warning
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册