diff --git a/src/absil/illib.fs b/src/absil/illib.fs index 2fdd5f1d21ec9e426d28d67a8817063ebe2c18a7..47f169935cb9acb2c0bb3e402742f7f36d29ed49 100644 --- a/src/absil/illib.fs +++ b/src/absil/illib.fs @@ -330,13 +330,6 @@ module List = | [] -> None | h :: t -> if f h then Some (h, List.rev acc @ t) else loop (h :: acc) t loop [] inp - - let headAndTail l = - match l with - | [] -> - Debug.Assert(false, "empty list") - failwith "List.headAndTail" - | h :: t -> h, t let zip4 l1 l2 l3 l4 = List.zip l1 (List.zip3 l2 l3 l4) |> List.map (fun (x1, (x2, x3, x4)) -> (x1, x2, x3, x4)) diff --git a/src/fsharp/MethodCalls.fs b/src/fsharp/MethodCalls.fs index 518fc640916537998f367e1f4b35e9aaf197cd22..4ffe1797123c51d6a6de00ee50f52e8a9b45881c 100644 --- a/src/fsharp/MethodCalls.fs +++ b/src/fsharp/MethodCalls.fs @@ -1867,12 +1867,15 @@ let GenWitnessExpr amap g m (traitInfo: TraitConstraintInfo) argExprs = // Fix bug 1281: If we resolve to an instance method on a struct and we haven't yet taken // the address of the object then go do that - if minfo.IsStruct && minfo.IsInstance && (match argExprs with [] -> false | h :: _ -> not (isByrefTy g (tyOfExpr g h))) then - let h, t = List.headAndTail argExprs - let wrap, h', _readonly, _writeonly = mkExprAddrOfExpr g true false PossiblyMutates h None m - Some (wrap (Expr.Op (TOp.TraitCall traitInfo, [], (h' :: t), m))) + if minfo.IsStruct && minfo.IsInstance then + match argExprs with + | h :: t when not (isByrefTy g (tyOfExpr g h)) -> + let wrap, h', _readonly, _writeonly = mkExprAddrOfExpr g true false PossiblyMutates h None m + Some (wrap (Expr.Op (TOp.TraitCall traitInfo, [], (h' :: t), m))) + | _ -> + Some (MakeMethInfoCall amap m minfo methArgTys argExprs) else - Some (MakeMethInfoCall amap m minfo methArgTys argExprs ) + Some (MakeMethInfoCall amap m minfo methArgTys argExprs) | Choice2Of5 (tinst, rfref, isSet) -> match isSet, rfref.RecdField.IsStatic, argExprs.Length with diff --git a/src/fsharp/NicePrint.fs b/src/fsharp/NicePrint.fs index 84b2904ad5232aa0150434834ff765aa0f275747..9a966e8e4331b20860b068f570da8296b3172810 100755 --- a/src/fsharp/NicePrint.fs +++ b/src/fsharp/NicePrint.fs @@ -1472,12 +1472,14 @@ module InfoMemberPrinting = let prettifyILMethInfo (amap: Import.ImportMap) m (minfo: MethInfo) typarInst ilMethInfo = let (ILMethInfo(_, apparentTy, dty, mdef, _)) = ilMethInfo let (prettyTyparInst, prettyTys), _ = PrettyTypes.PrettifyInstAndTypes amap.g (typarInst, (apparentTy :: minfo.FormalMethodInst)) - let prettyApparentTy, prettyFormalMethInst = List.headAndTail prettyTys - let prettyMethInfo = - match dty with - | None -> MethInfo.CreateILMeth (amap, m, prettyApparentTy, mdef) - | Some declaringTyconRef -> MethInfo.CreateILExtensionMeth(amap, m, prettyApparentTy, declaringTyconRef, minfo.ExtensionMemberPriorityOption, mdef) - prettyTyparInst, prettyMethInfo, prettyFormalMethInst + match prettyTys with + | prettyApparentTy :: prettyFormalMethInst -> + let prettyMethInfo = + match dty with + | None -> MethInfo.CreateILMeth (amap, m, prettyApparentTy, mdef) + | Some declaringTyconRef -> MethInfo.CreateILExtensionMeth(amap, m, prettyApparentTy, declaringTyconRef, minfo.ExtensionMemberPriorityOption, mdef) + prettyTyparInst, prettyMethInfo, prettyFormalMethInst + | _ -> failwith "prettifyILMethInfo - prettyTys empty" /// Format a method to a buffer using "standalone" display style. /// For example, these are the formats used when printing signatures of methods that have not been overridden, diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index 9abd05cfd58765f42b092c16310b3aab78b5922b..2df03cef263d654defa5d81c428de668c8d82400 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -9265,9 +9265,8 @@ and TcNameOfExpr cenv env tpenv (synArg: SynExpr) = let m = cleanSynArg.Range let rec check overallTyOpt expr (delayed: DelayedItem list) = match expr with - | LongOrSingleIdent (false, (LongIdentWithDots(longId, _) as lidd), _, _) when longId.Length > 0 -> + | LongOrSingleIdent (false, (LongIdentWithDots((id::rest) as longId, _) as lidd), _, _) -> let ad = env.eAccessRights - let id, rest = List.headAndTail longId match ResolveLongIndentAsModuleOrNamespaceOrStaticClass cenv.tcSink ResultCollectionSettings.AllResults cenv.amap m false true OpenQualified env.eNameResEnv ad id rest true with | Result modref when delayed.IsEmpty && modref |> List.exists (p23 >> IsEntityAccessible cenv.amap m ad) -> () // resolved to a module or namespace, done with checks diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index 3520cc7b2fe39cfab679701137710ae32f7807f9..e263e8371c0401f5d4cfd45574481d8c98713b78 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -2266,10 +2266,15 @@ type internal FsiInteractionProcessor // When the last declaration has a shape of DoExp (i.e., non-binding), // transform it to a shape of "let it = ", so we can refer it. - let defsA = if defsA.Length <= 1 || not (List.isEmpty defsB) then defsA else - match List.headAndTail (List.rev defsA) with - | SynModuleDecl.DoExpr(_,exp,_), rest -> (rest |> List.rev) @ (fsiDynamicCompiler.BuildItBinding exp) - | _ -> defsA + let defsA = + if not (isNil defsB) then defsA else + match defsA with + | [] -> defsA + | [_] -> defsA + | _ -> + match List.rev defsA with + | SynModuleDecl.DoExpr(_,exp,_) :: rest -> (rest |> List.rev) @ (fsiDynamicCompiler.BuildItBinding exp) + | _ -> defsA Some (IDefns(defsA,m)),Some (IDefns(defsB,m)),istate