Closed bellard closed 4 months ago
This patch is not correct because "null" is a valid exception. Currently, the only way to test an exception is to test if JS_EXCEPTION is returned. The content of "current_exception" is undefined otherwise.
Would it be reasonable to make the contents of current_exception
defined at all times so one can actually test for pending exceptions?
null
is a valid exception, so testing for JS_NULL
is not correct even if current_exception
is defined all the time (try throw null
). We may initialize it to JS_UNINITIALIZED
instead.
That's an awfully good point! Initialising it to JS_UNINITIALIZED
instead and letting that mean "no pending exception" sounds like a plan, I can put together a PR.
That's an awfully good point! Initialising it to
JS_UNINITIALIZED
instead and letting that mean "no pending exception" sounds like a plan, I can put together a PR.
Using JS_UNINITIALIZED
is indeed a clever way to allow for any valid value to be thrown.
@chqrlie Isn't JS_UNDEFINED
it's own thing?
@chqrlie Isn't
JS_UNDEFINED
it's own thing?
Yes, I was confused in my earlier comment. JS_UNDEFINED
and JS_UNINITIALIZED
are different types, JS_UNINITALIZED
is used for special let
semantics and is a perfect solution for the issue at stake here.
This reverts commit db9dbd0a2b6d115c9ef3c0dc37e0c669ef4844e4.