Skip to content

Commit 87f65b2

Browse files
authored
Merge pull request #8280 from dotnet/merges/master-to-feature/and-bang
Merge master to feature/and-bang
2 parents 4fa74be + e07132b commit 87f65b2

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

src/absil/bytes.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type ByteArrayMemory(bytes: byte[], offset, length) =
6767
inherit ByteMemory()
6868

6969
do
70-
if length <= 0 || length > bytes.Length then
70+
if length < 0 || length > bytes.Length then
7171
raise (ArgumentOutOfRangeException("length"))
7272

7373
if offset < 0 || (offset + length) > bytes.Length then
@@ -155,7 +155,7 @@ type RawByteMemory(addr: nativeptr<byte>, length: int, hold: obj) =
155155
raise (ArgumentOutOfRangeException("i"))
156156

157157
do
158-
if length <= 0 then
158+
if length < 0 then
159159
raise (ArgumentOutOfRangeException("length"))
160160

161161
override _.Item

src/fsharp/FSharp.Core/list.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,13 @@ namespace Microsoft.FSharp.Collections
171171
[<CompiledName("Initialize")>]
172172
let init length initializer = Microsoft.FSharp.Primitives.Basics.List.init length initializer
173173

174-
let rec initConstAcc n x acc =
175-
if n <= 0 then acc else initConstAcc (n-1) x (x :: acc)
176-
177174
[<CompiledName("Replicate")>]
178175
let replicate count initial =
179176
if count < 0 then invalidArg "count" (SR.GetString(SR.inputMustBeNonNegative))
180-
initConstAcc count initial []
177+
let mutable result = []
178+
for i in 0..count-1 do
179+
result <- initial :: result
180+
result
181181

182182
[<CompiledName("Iterate2")>]
183183
let iter2 action list1 list2 =

src/fsharp/FSharp.Core/local.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ open System.Collections.Generic
8383

8484
module internal List =
8585

86-
let arrayZeroCreate (n:int) = (# "newarr !0" type ('T) n : 'T array #)
86+
let inline arrayZeroCreate (n:int) = (# "newarr !0" type ('T) n : 'T array #)
8787

8888
[<SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")>]
8989
let nonempty x = match x with [] -> false | _ -> true

src/fsharp/NameResolution.fs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3214,11 +3214,12 @@ let ResolveFieldPrim sink (ncenv: NameResolver) nenv ad ty (mp, id: Ident) allFi
32143214
|> ListSet.setify (fun fref1 fref2 -> tyconRefEq g fref1.TyconRef fref2.TyconRef)
32153215
|> List.map (fun x -> ResolutionInfo.Empty, FieldResolution(x, false))
32163216

3217-
if isAppTy g ty then
3217+
match tryDestAppTy g ty with
3218+
| ValueSome tcref ->
32183219
match ncenv.InfoReader.TryFindRecdOrClassFieldInfoOfType(id.idText, m, ty) with
32193220
| ValueSome (RecdFieldInfo(_, rfref)) -> [ResolutionInfo.Empty, FieldResolution(rfref, false)]
32203221
| _ ->
3221-
if isRecdTy g ty then
3222+
if tcref.IsRecordTycon then
32223223
// record label doesn't belong to record type -> suggest other labels of same record
32233224
let suggestLabels (addToBuffer: string -> unit) =
32243225
for label in SuggestOtherLabelsOfSameRecordType g nenv ty id allFields do
@@ -3229,7 +3230,7 @@ let ResolveFieldPrim sink (ncenv: NameResolver) nenv ad ty (mp, id: Ident) allFi
32293230
error(ErrorWithSuggestions(errorText, m, id.idText, suggestLabels))
32303231
else
32313232
lookup()
3232-
else
3233+
| _ ->
32333234
lookup()
32343235
| _ ->
32353236
let lid = (mp@[id])

src/fsharp/TypeChecker.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5474,7 +5474,7 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv, names, takenNames) ty p
54745474
| [SynPatErrorSkip(SynPat.Tuple (false, args, _)) | SynPatErrorSkip(SynPat.Paren(SynPatErrorSkip(SynPat.Tuple (false, args, _)), _))] when numArgTys > 1 -> args
54755475

54765476
// note: we allow both 'C _' and 'C (_)' regardless of number of argument of the pattern
5477-
| [SynPatErrorSkip(SynPat.Wild _ as e) | SynPatErrorSkip(SynPat.Paren(SynPatErrorSkip(SynPat.Wild _ as e), _))] -> Array.toList (Array.create numArgTys e)
5477+
| [SynPatErrorSkip(SynPat.Wild _ as e) | SynPatErrorSkip(SynPat.Paren(SynPatErrorSkip(SynPat.Wild _ as e), _))] -> List.replicate numArgTys e
54785478
| [arg] -> [arg]
54795479
| _ when numArgTys = 0 -> error(Error(FSComp.SR.tcUnionCaseDoesNotTakeArguments(), m))
54805480
| _ when numArgTys = 1 -> error(Error(FSComp.SR.tcUnionCaseRequiresOneArgument(), m))
@@ -6868,7 +6868,7 @@ and TcObjectExpr cenv overallTy env tpenv (synObjTy, argopt, binds, extraImpls,
68686868
match tryDestAppTy cenv.g objTy with
68696869
| ValueNone -> error(Error(FSComp.SR.tcNewMustBeUsedWithNamedType(), mNewExpr))
68706870
| ValueSome tcref ->
6871-
let isRecordTy = isRecdTy cenv.g objTy
6871+
let isRecordTy = tcref.IsRecordTycon
68726872
if not isRecordTy && not (isInterfaceTy cenv.g objTy) && isSealedTy cenv.g objTy then errorR(Error(FSComp.SR.tcCannotCreateExtensionOfSealedType(), mNewExpr))
68736873

68746874
CheckSuperType cenv objTy synObjTy.Range
@@ -7257,12 +7257,12 @@ and TcAnonRecdExpr cenv overallTy env tpenv (isStruct, optOrigSynExpr, unsortedF
72577257
for (i, id) in Array.indexed anonInfo.SortedIds do
72587258
yield id, Choice2Of2 (mkAnonRecdFieldGetViaExprAddr (anonInfo, oldveaddr, tinst, i, mOrigExpr))
72597259
| ValueNone ->
7260-
if isRecdTy cenv.g origExprTy then
7261-
let tcref, tinst = destAppTy cenv.g origExprTy
7260+
match tryAppTy cenv.g origExprTy with
7261+
| ValueSome(tcref, tinst) when tcref.IsRecordTycon ->
72627262
let fspecs = tcref.Deref.TrueInstanceFieldsAsList
72637263
for fspec in fspecs do
72647264
yield fspec.Id, Choice2Of2 (mkRecdFieldGetViaExprAddr (oldveaddr, tcref.MakeNestedRecdFieldRef fspec, tinst, mOrigExpr))
7265-
else
7265+
| _ ->
72667266
error (Error (FSComp.SR.tcCopyAndUpdateNeedsRecordType(), mOrigExpr)) |]
72677267
|> Array.distinctBy (fst >> textOfId)
72687268

0 commit comments

Comments
 (0)