Fix overly-wide exception catches in the display/typing pipeline#12819
Fix overly-wide exception catches in the display/typing pipeline#12819Copilot wants to merge 1 commit into
Conversation
Cancelled and JsonCompleted
|
@copilot Please update the branch, there is a conflict now. But also, while this might be a good ad-hoc fix, it doesn't actually address the underlying problem. What we should really investigate is why these catch-all sites exist in the first place and if they should be restructured to either cover less ground or catch more specific exceptions. Otherwise we'll have the same issue with the next "global" exception that we want to bubble up. |
Resolved the conflict and addressed the underlying concern in 7e4d39b. Instead of ad-hocly re-raising
With specific catches, any exception not in the list — including |
Cancelled and JsonCompleted|
@copilot Somehow there's still a conflict and you've made a branching mess. See that your changes are based on 517a97a, which is the latest commit on development. |
7e4d39b to
934da02
Compare
Based on 517a97a (latest development commit). Each broad | _ -> catch in the display/typing pipeline is replaced with an enumeration of only the specific compilation-error exception types that the try block legitimately expects to raise. Any exception not in the list naturally bubbles up without requiring per-exception holes. Co-authored-by: Simn <634365+Simn@users.noreply.github.com>
934da02 to
18b891e
Compare
Resolved in 18b891e. The branch is now a single commit directly on top of |
|
Oh man I'll have to carefully review this. But I do think it's worthwhile because the catches can be VERY confusing in some cases. |
Generic
| _ ->catch patterns throughout the display/typing pipeline were silently swallowing control-flow exceptions likeGlobals.Cancelled(cooperative server cancellation) andDisplayJson.JsonCompleted(JSON-RPC response sent signal), preventing them from bubbling up to the compilation entry point as required.Critical fix
compiler.mlcompile_safe:Globals.Cancelledwas absent from the re-raise list, so a cancelled server compilation in production mode would be silently converted into a spurious error message instead of propagating torun_request'sCancelledhandler.Display/typing path fixes
Each broad
| _ ->catch-all is replaced with an enumeration of only the specific compilation-error exception types that the try block is legitimately expected to raise. Any exception not in the enumerated list — includingGlobals.Cancelled,DisplayJson.JsonCompleted, and any future control-flow exceptions — naturally bubbles up to the appropriate handler.displayProcessing.mlload_display_module_in_macro— catchesError.Fatal_error _ | Error.Error _ | Failure _ | Not_found | Lexer.Error _ | Parser.Error _ | Typecore.Forbid_package _ | Typecore.WithTypeError _macroContext.ml— bothparse_metadatafunctions narrowed toLexer.Error _ | Failure _(only exceptions that can escape theParseErrorbranch)displayToplevel.ml—maybe_resolve_macro_fieldand the removed-files parse loopdisplay.ml—get_import_statuscatchesNot_found | Error.Fatal_error _ | Error.Error _ | Failure _typerDisplay.ml—retypehelper and the constructor-filter predicate catch typing error exceptionssyntaxExplorer.ml—explore_uncached_modulesmodule load loopcommonCache.ml— native lib build taskdisplayPath.ml—complete_type_path_innerdisplayFields.ml— all three broad catches inhandle_missing_field_raisePattern used
This approach is robust against future additions: any new control-flow exception will automatically bubble up without requiring per-exception patches at each catch site.
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.