Skip to content
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
7 changes: 4 additions & 3 deletions src/fsharp/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3214,11 +3214,12 @@ let ResolveFieldPrim sink (ncenv: NameResolver) nenv ad ty (mp, id: Ident) allFi
|> ListSet.setify (fun fref1 fref2 -> tyconRefEq g fref1.TyconRef fref2.TyconRef)
|> List.map (fun x -> ResolutionInfo.Empty, FieldResolution(x, false))

if isAppTy g ty then
match tryDestAppTy g ty with
| ValueSome tcref ->
match ncenv.InfoReader.TryFindRecdOrClassFieldInfoOfType(id.idText, m, ty) with
| ValueSome (RecdFieldInfo(_, rfref)) -> [ResolutionInfo.Empty, FieldResolution(rfref, false)]
| _ ->
if isRecdTy g ty then
if tcref.IsRecordTycon then
// record label doesn't belong to record type -> suggest other labels of same record
let suggestLabels (addToBuffer: string -> unit) =
for label in SuggestOtherLabelsOfSameRecordType g nenv ty id allFields do
Expand All @@ -3229,7 +3230,7 @@ let ResolveFieldPrim sink (ncenv: NameResolver) nenv ad ty (mp, id: Ident) allFi
error(ErrorWithSuggestions(errorText, m, id.idText, suggestLabels))
else
lookup()
else
| _ ->
lookup()
| _ ->
let lid = (mp@[id])
Expand Down
8 changes: 4 additions & 4 deletions src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6876,7 +6876,7 @@ and TcObjectExpr cenv overallTy env tpenv (synObjTy, argopt, binds, extraImpls,
match tryDestAppTy cenv.g objTy with
| ValueNone -> error(Error(FSComp.SR.tcNewMustBeUsedWithNamedType(), mNewExpr))
| ValueSome tcref ->
let isRecordTy = isRecdTy cenv.g objTy
let isRecordTy = tcref.IsRecordTycon
if not isRecordTy && not (isInterfaceTy cenv.g objTy) && isSealedTy cenv.g objTy then errorR(Error(FSComp.SR.tcCannotCreateExtensionOfSealedType(), mNewExpr))

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

Expand Down