Skip to content
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

Revert "Add JS_HasException() (#265)" #312

Closed
wants to merge 1 commit into from

Conversation

bellard
Copy link
Owner

@bellard bellard commented May 30, 2024

This reverts commit db9dbd0.

@bellard
Copy link
Owner Author

bellard commented May 30, 2024

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.

@kasperisager
Copy link
Contributor

kasperisager commented May 30, 2024

Would it be reasonable to make the contents of current_exception defined at all times so one can actually test for pending exceptions?

@bellard
Copy link
Owner Author

bellard commented May 30, 2024

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.

@kasperisager
Copy link
Contributor

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.

@chqrlie
Copy link
Collaborator

chqrlie commented May 30, 2024

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.

@kasperisager
Copy link
Contributor

@chqrlie Isn't JS_UNDEFINED it's own thing?

@chqrlie
Copy link
Collaborator

chqrlie commented May 31, 2024

@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.

@chqrlie chqrlie closed this in #313 Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants