Interpreter: Catch Invalid_argument more locally #1736
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
previously, we would catch
Invalid_argument
and turn it into aTrap
very coarsly. The coarse
catch
aroundinterpret_block
was added in1e1757a
but now also catches
Invalid_argument
exceptions that should not becaught.
Instead, we need to to
try … with
precisely the points where we expectan
Invalid_argument
to stand for something trapping. In this casePrim.prim.
Prim.prim
can't raise trap itself, asTrap
is defined in the twointerpreters, and because it doesn't have accees to the
exp.at
.So this wraps invocations to
Prim.prim
, following similar patters forbinop
etc.It also simplifies the type signature of
Prim.num_conv_prim
, making itclear that this is just a self-contained call-by-value function.
Otherwise, we’d still catch
Invalid_argument
exceptions raised by thecontinuation that
num_conv_prim
invokes.The same should be applied to
Prim.prim
, but we can’t, becauseArray.tabulate
is higher order and inovkes a function. But still, thisis an improvement of the status quo.
See https://dfinity.slack.com/archives/CPL67E7MX/p1594979459058400?thread_ts=1594977500.055800&cid=CPL67E7MX