-
Notifications
You must be signed in to change notification settings - Fork 410
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
Do not use the transitive closure in generated META files #405
Conversation
0f4adda
to
8d2bbd9
Compare
src/lib_db.ml
Outdated
| x -> Inl [x] | ||
| exception e -> | ||
(* Call [find] again to get a proper backtrace *) | ||
Inr { fail = fun () -> ignore (find_exn t ~from:dir name : Lib.t); raise e } |
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.
Would you mind explaining this trick a bit? How does calling find_exn again get us a proper back trace? Isn't it going to just raise and we won't re-raise e?
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.
yes, that's the expectation. In fact we could just replace the raise e
by assert false
. By calling find_exn
, we get a more precise backtrace. For instance it might start in findlib.ml
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.
OK, I think doing assert false
will be a little nicer since we won't even have to bind e
in the pattern match.
List.map (String_set.elements required) ~f:(find_exn t ~from:dir) | ||
with | ||
| l -> Some l | ||
| exception _ -> None) |
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.
Unrelated: Maybe we should just add Option.try_with
I see that we do this idiom in a few places already.
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.
indeed
Currently, in META files jbuilder uses the transitive closure in
requires
andppx_runtime_deps
variables. I can't remember why I did that but it seems simpler not to do that.The generated META files are smaller, It simplifies the code and in any case it's likely that using the transitive closure won't be compatible with library variants.