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

[Merged by Bors] - Generic JsResult<R> in context.throw_ methods #1734

Closed
wants to merge 1 commit into from

Conversation

HalidOdat
Copy link
Member

Previously when we had the context.throw_ methods (like context.thtrow_type_error()) they were limited as to where we could call them, e.i. a function that returned JsResult<JsValue>. So we had to call the context.construct_ methods with an explicit Err() enum wrap to throw in functions that returned non-jsvalues (which happens a lot).
Now, with this PR the throw methods have a generic JsResult<R> return that can return in any JsResult<T> returning function. Which cleans the API and makes the user experience a bit better.

return Err(context.construct_type_error("..."));
// to
return context.throw_type_error("...");

@HalidOdat HalidOdat added enhancement New feature or request API labels Dec 6, 2021
@HalidOdat HalidOdat added this to the v0.14.0 milestone Dec 6, 2021
@github-actions
Copy link

github-actions bot commented Dec 6, 2021

Test262 conformance changes

Non-VM implementation

Test result main count PR count difference
Total 86,952 86,952 0
Passed 40,111 40,111 0
Ignored 19,269 19,269 0
Failed 27,572 27,572 0
Panics 0 0 0
Conformance 46.13% 46.13% 0.00%

VM implementation

Test result main count PR count difference
Total 86,952 86,952 0
Passed 39,654 39,654 0
Ignored 19,269 19,269 0
Failed 28,029 28,029 0
Panics 189 189 0
Conformance 45.60% 45.60% 0.00%

@codecov
Copy link

codecov bot commented Dec 6, 2021

Codecov Report

Merging #1734 (5fcf232) into main (e1b2abb) will increase coverage by 0.04%.
The diff coverage is 15.68%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1734      +/-   ##
==========================================
+ Coverage   53.33%   53.38%   +0.04%     
==========================================
  Files         200      200              
  Lines       16983    16967      -16     
==========================================
- Hits         9058     9057       -1     
+ Misses       7925     7910      -15     
Impacted Files Coverage Δ
boa/src/builtins/array/mod.rs 77.76% <0.00%> (ø)
boa/src/builtins/array_buffer/mod.rs 6.77% <0.00%> (ø)
boa/src/builtins/intl/mod.rs 19.35% <0.00%> (ø)
boa/src/builtins/iterable/mod.rs 61.64% <0.00%> (ø)
boa/src/builtins/number/mod.rs 79.55% <0.00%> (ø)
boa/src/builtins/typed_array/mod.rs 3.79% <0.00%> (ø)
.../src/environment/declarative_environment_record.rs 65.07% <0.00%> (ø)
boa/src/environment/global_environment_record.rs 40.56% <0.00%> (ø)
boa/src/environment/object_environment_record.rs 25.58% <0.00%> (ø)
boa/src/object/internal_methods/array.rs 76.56% <0.00%> (ø)
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1b2abb...5fcf232. Read the comment docs.

Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! For a second there I thought we already had this, but indeed, this extra generic parameter makes it much more useful, since it can basically be used everywhere.

I'm approving the PR, even if there seems to be something strange with the test suite. Could you check that? Maybe the sub-module needs updating.

@HalidOdat
Copy link
Member Author

I'm approving the PR, even if there seems to be something strange with the test suite. Could you check that? Maybe the sub-module needs updating.

Yes, it was out of date, I updated it and committed it :)

Copy link
Member

@RageKnify RageKnify left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

bors bot pushed a commit that referenced this pull request Dec 6, 2021
Previously when we had the `context.throw_` methods (like `context.thtrow_type_error()`) they were limited as to where we could call them, e.i. a function that returned `JsResult<JsValue>`. So we had to call the `context.construct_` methods with an explicit `Err()` enum wrap to throw in functions that returned non-jsvalues (which happens a lot).
Now, with this PR the throw methods have a generic `JsResult<R>` return that can return in any `JsResult<T>` returning function. Which cleans the API and makes the user experience a bit better.

```rust
return Err(context.construct_type_error("..."));
// to
return context.throw_type_error("...");
```
@bors
Copy link

bors bot commented Dec 6, 2021

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Generic JsResult<R> in context.throw_ methods [Merged by Bors] - Generic JsResult<R> in context.throw_ methods Dec 6, 2021
@bors bors bot closed this Dec 6, 2021
@bors bors bot deleted the feature/context-throwing branch December 6, 2021 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants