-
Notifications
You must be signed in to change notification settings - Fork 484
Make inclusion error output independent of the source path #8691
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -634,16 +634,37 @@ let include_err ppf (cxt, env, err) = | |
| Printtyp.wrap_printing_env env (fun () -> | ||
| fprintf ppf "@[<v>%a%a@]" context (List.rev cxt) (include_symptom env) err) | ||
|
|
||
| let buffer = ref Bytes.empty | ||
| (* An error part is big when its heap representation exceeds | ||
| [!Clflags.error_size] words. Each distinct reachable block counts its header | ||
| and fields; a block without scannable fields (string, float, custom) or a | ||
| closure counts its header only. String contents are excluded so that the | ||
| decision is independent of source file names stored in locations. The walk | ||
| stops as soon as the limit is exceeded, which bounds the visited list. *) | ||
|
Comment on lines
+637
to
+642
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 changes compiler diagnostics that users see, but the commit does not update AGENTS.md reference: AGENTS.md:L93-L95 Useful? React with 👍 / 👎.
Collaborator
Author
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. Added in 5eb5ae9, under the Unreleased section with the PR link. |
||
| let is_big obj = | ||
| let size = !Clflags.error_size in | ||
| size > 0 | ||
| && | ||
| (if Bytes.length !buffer < size then buffer := Bytes.create size; | ||
| try | ||
| ignore (Marshal.to_buffer !buffer 0 size obj []); | ||
| false | ||
| with _ -> true) | ||
| let limit = !Clflags.error_size in | ||
| let size = ref 0 in | ||
| let visited = ref [] in | ||
| let exception Big in | ||
| let rec walk (o : Obj.t) = | ||
| if Obj.is_block o && not (List.memq o !visited) then ( | ||
| visited := o :: !visited; | ||
| let tag = Obj.tag o in | ||
| let scan = | ||
| tag < Obj.no_scan_tag && tag <> Obj.closure_tag && tag <> Obj.infix_tag | ||
| in | ||
| size := !size + if scan then 1 + Obj.size o else 1; | ||
| if !size > limit then raise_notrace Big; | ||
| if scan then | ||
| for i = 0 to Obj.size o - 1 do | ||
| walk (Obj.field o i) | ||
| done) | ||
| in | ||
| if limit <= 0 then false | ||
| else | ||
| try | ||
| walk (Obj.repr obj); | ||
| false | ||
| with Big -> true | ||
|
|
||
| let report_error ppf errs = | ||
| if errs = [] then () | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.