Merge pull request #9469 from lpw25/fix-lazy-backtraces

Better backtraces for lazy values
master
Nicolás Ojeda Bär 2020-06-14 11:34:04 +02:00 committed by GitHub
commit 33416d11db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 1 deletions

View File

@ -167,6 +167,9 @@ Working version
### Bug fixes: ### Bug fixes:
- #9469: Better backtraces for lazy values
(Leo White, review by Nicolás Ojeda Bär)
- #9521, #9522: correctly fail when comparing functions - #9521, #9522: correctly fail when comparing functions
with Closure and Infix tags. with Closure and Infix tags.
(Gabriel Scherer and Jeremy Yallop and Xavier Leroy, (Gabriel Scherer and Jeremy Yallop and Xavier Leroy,

View File

@ -679,7 +679,7 @@ let lambda_of_prim prim_name prim loc args arg_exps =
loc), loc),
Lprim(Praise Raise_reraise, [raise_arg], loc))) Lprim(Praise Raise_reraise, [raise_arg], loc)))
| Lazy_force, [arg] -> | Lazy_force, [arg] ->
Matching.inline_lazy_force arg Loc_unknown Matching.inline_lazy_force arg loc
| Loc kind, [] -> | Loc kind, [] ->
lambda_of_loc kind loc lambda_of_loc kind loc
| Loc kind, [arg] -> | Loc kind, [arg] ->

View File

@ -0,0 +1,28 @@
(* TEST
flags = "-g"
compare_programs = "false"
* native
*)
let l1 : unit lazy_t = lazy (raise Not_found)
let test1 () =
let () = Lazy.force l1 in ()
let l2 : unit lazy_t = lazy (raise Not_found)
let test2 () =
let (lazy ()) = l2 in ()
let run test =
try
test ();
with exn ->
Printf.printf "Uncaught exception %s\n" (Printexc.to_string exn);
Printexc.print_backtrace stdout
let () =
Printexc.record_backtrace true;
run test1;
run test2

View File

@ -0,0 +1,12 @@
Uncaught exception Not_found
Raised at Lazy.l1 in file "lazy.ml", line 8, characters 28-45
Called from CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 31, characters 17-27
Re-raised at CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 36, characters 4-11
Called from Lazy.test1 in file "lazy.ml", line 11, characters 11-24
Called from Lazy.run in file "lazy.ml", line 20, characters 4-11
Uncaught exception Not_found
Raised at Lazy.l2 in file "lazy.ml", line 13, characters 28-45
Called from CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 31, characters 17-27
Re-raised at CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 36, characters 4-11
Called from Lazy.test2 in file "lazy.ml", line 16, characters 6-15
Called from Lazy.run in file "lazy.ml", line 20, characters 4-11