Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use length if we can pattern match #5716

Merged
merged 2 commits into from
Oct 2, 2018
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
3 changes: 1 addition & 2 deletions src/fsharp/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,7 @@ let private GetCSharpStyleIndexedExtensionMembersForTyconRef (amap:Import.Import
// Method must be static, have 'Extension' attribute, must not be curried, must have at least one argument
if not minfo.IsInstance &&
not minfo.IsExtensionMember &&
minfo.NumArgs.Length = 1 &&
minfo.NumArgs.Head >= 1 &&
(match minfo.NumArgs with [x] when x >= 1 -> true | _ -> false) &&
MethInfoHasAttribute g m g.attrib_ExtensionAttribute minfo
then
let ilExtMem = ILExtMem (tcrefOfStaticClass, minfo, pri)
Expand Down
3 changes: 2 additions & 1 deletion src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1923,6 +1923,7 @@ let FreshenAbstractSlot g amap m synTyparDecls absMethInfo =
let BuildFieldMap cenv env isPartial ty flds m =
let ad = env.eAccessRights
if isNil flds then invalidArg "flds" "BuildFieldMap"
let fldCount = flds.Length

let frefSets =
let allFields = flds |> List.map (fun ((_, ident), _) -> ident)
Expand All @@ -1942,7 +1943,7 @@ let BuildFieldMap cenv env isPartial ty flds m =
warning (Error(FSComp.SR.tcFieldsDoNotDetermineUniqueRecordType(), m))

// try finding a record type with the same number of fields as the ones that are given.
match tcrefs |> List.tryFind (fun tc -> tc.TrueFieldsAsList.Length = flds.Length) with
match tcrefs |> List.tryFind (fun tc -> tc.TrueFieldsAsList.Length = fldCount) with
| Some tcref -> tcref
| _ ->
// OK, there isn't a unique, good type dictated by the intersection for the field refs.
Expand Down