-
Notifications
You must be signed in to change notification settings - Fork 74
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
Avoid costly errors in JS witness generation #830
Changes from 3 commits
edc262c
e72bb22
45060ee
03f03ed
627c3c1
deda9f9
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 |
---|---|---|
|
@@ -28,9 +28,10 @@ module Handler = struct | |
fun stack0 label_stack req0 -> | ||
let rec go req = function | ||
| [] -> | ||
failwith | ||
( "Unhandled request: " | ||
^ Core_kernel.String.concat ~sep:"\n" label_stack ) | ||
raise | ||
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. As above, this should probably return an 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. good point! will change |
||
(Failure | ||
( "Unhandled request: " | ||
^ Core_kernel.String.concat ~sep:"\n" label_stack ) ) | ||
| { handle } :: hs -> ( | ||
match handle req with | ||
| Provide x -> | ||
|
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.
I'm just replacing
failwith s
withraise (Failure s)
. This makes a difference because in JS, we use a custom override of thefailwith
function, to have it throw JS errors instead of strings. This is very important in a couple of circumstances where the error implies an actual failure condition. Here, the error is just used for control flow and always caught a level earlier, so we don't need a pretty error.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.
If you don't want to pay the cost of the exception here, can you change the code above it to use an
val of_basic : ('v, 'f) basic -> ('v, 'f) t option
instead.