-
Notifications
You must be signed in to change notification settings - Fork 860
Report FS0039 only once for undefined type in inherit clause #19862
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
base: main
Are you sure you want to change the base?
Changes from all commits
12ae67e
57ffff0
c2735ab
e34c612
88a176e
966314a
6c99c8c
d34b815
4968066
e2bd7bf
8dfccdb
73e5702
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,15 @@ open FSharp.Compiler.TypeProviders | |
|
|
||
| type cenv = TcFileState | ||
|
|
||
| let rec (|UndefinedNameError|_|) (e: exn) = | ||
| match e with | ||
| | UndefinedName _ -> Some () | ||
| | WrappedError(inner, _) | ||
| | ErrorFromAddingTypeEquation(error = inner) | ||
| | ErrorFromAddingConstraint(error = inner) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is definitely not a undefined name error. |
||
| | ErrorFromApplyingDefault(error = inner) -> (|UndefinedNameError|_|) inner | ||
| | _ -> None | ||
|
|
||
| //------------------------------------------------------------------------- | ||
| // Mutually recursive shapes | ||
| //------------------------------------------------------------------------- | ||
|
|
@@ -1367,14 +1376,17 @@ module MutRecBindingChecking = | |
| // Phase2B: typecheck the argument to an 'inherits' call and build the new object expr for the inherit-call | ||
| | Phase2AInherit (synBaseTy, arg, baseValOpt, m) -> | ||
| let inheritsExpr, tpenv = | ||
| try | ||
| let baseTy, tpenv = TcType cenv NoNewTypars CheckCxs ItemOccurrence.Use WarnOnIWSAM.Yes envInstance tpenv synBaseTy | ||
| let baseTy = baseTy |> convertToTypeWithMetadataIfPossible g | ||
| let mTcNew = unionRanges synBaseTy.Range arg.Range | ||
| TcNewExpr cenv envInstance tpenv baseTy (Some synBaseTy.Range) true arg mTcNew | ||
| with RecoverableException e -> | ||
| errorRecovery e m | ||
| if cenv.inheritResolutionFailed.ContainsKey(struct (tcref.Stamp, synBaseTy.Range)) then | ||
| mkUnit g m, tpenv | ||
| else | ||
|
Comment on lines
+1379
to
+1381
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I'm following the idea. If there was an error previously then we skip the analysis and if there wasn't we still do it the second time? Why do we need to resolve the same identifiers more than once at all? |
||
| try | ||
| let baseTy, tpenv = TcType cenv NoNewTypars CheckCxs ItemOccurrence.Use WarnOnIWSAM.Yes envInstance tpenv synBaseTy | ||
| let baseTy = baseTy |> convertToTypeWithMetadataIfPossible g | ||
| let mTcNew = unionRanges synBaseTy.Range arg.Range | ||
| TcNewExpr cenv envInstance tpenv baseTy (Some synBaseTy.Range) true arg mTcNew | ||
| with RecoverableException e -> | ||
| errorRecovery e m | ||
| mkUnit g m, tpenv | ||
| let envInstance = match baseValOpt with Some baseVal -> AddLocalVal g cenv.tcSink scopem baseVal envInstance | None -> envInstance | ||
| let envNonRec = match baseValOpt with Some baseVal -> AddLocalVal g cenv.tcSink scopem baseVal envNonRec | None -> envNonRec | ||
| let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) | ||
|
|
@@ -3317,7 +3329,23 @@ module EstablishTypeDefinitionCores = | |
| let kind = InferTyconKind g (kind, attrs, slotsigs, fields, inSig, isConcrete, m) | ||
|
|
||
| let inherits = inherits |> List.map (fun (ty, m, _) -> (ty, m)) | ||
| let inheritedTys = fst (List.mapFold (mapFoldFst (TcTypeAndRecover cenv NoNewTypars checkConstraints ItemOccurrence.UseInType WarnOnIWSAM.No envinner)) tpenv inherits) | ||
| let tryResolveInheritType tpenv (ty: SynType, m) = | ||
| let key = struct (tcref.Stamp, ty.Range) | ||
| if cenv.inheritResolutionFailed.ContainsKey key then | ||
| (g.obj_ty_ambivalent, m), tpenv | ||
| else | ||
| try | ||
| let resolved, tpenv = TcType cenv NoNewTypars checkConstraints ItemOccurrence.UseInType WarnOnIWSAM.No envinner tpenv ty | ||
| (resolved, m), tpenv | ||
| with | ||
| | RecoverableException (UndefinedNameError as e) -> | ||
| errorRecovery e ty.Range | ||
| cenv.inheritResolutionFailed.TryAdd(key, ()) |> ignore | ||
| (g.obj_ty_ambivalent, m), tpenv | ||
| | RecoverableException e -> | ||
| errorRecovery e ty.Range | ||
| (g.obj_ty_ambivalent, m), tpenv | ||
| let inheritedTys = inherits |> List.mapFold tryResolveInheritType tpenv |> fst | ||
| let implementedTys, inheritedTys = | ||
| match kind with | ||
| | SynTypeDefnKind.Interface -> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment duplicates the signature.