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

Added TypeError implementation #442

Merged
merged 2 commits into from Jun 2, 2020
Merged

Added TypeError implementation #442

merged 2 commits into from Jun 2, 2020

Conversation

HalidOdat
Copy link
Member

@HalidOdat HalidOdat commented Jun 2, 2020

It changes the following:

  • Added TypeError implementation.
  • Fixed RangeError and Error throwing.
  • Moved throwing code to Interpreter.
  • Added throw_range_error() and throw_type_error() to Interpreter.

Now with this PR it should be easier to throw exceptions, for example:

fn function_that_throws(_: &mut Value, args: &[Value], ctx: &mut Interpreter) -> ResultValue {
	if args.is_empty() {
		return ctx.throw_range_error("Some message");
	}
	
	ctx.throw_type_error("Some other message")
}

This is more or less the way neon crate does it.

 - Fixed `RangeError` and `Error` throwing.
 - Moved throwing code to Interperter.
 - Added throw_range_error() and throw_type_error() to Interperter.
@HalidOdat HalidOdat added bug Something isn't working enhancement New feature or request builtins PRs and Issues related to builtins/intrinsics labels Jun 2, 2020
@HalidOdat HalidOdat added this to the v0.9.0 milestone Jun 2, 2020
@codecov
Copy link

codecov bot commented Jun 2, 2020

Codecov Report

Merging #442 into master will increase coverage by 0.19%.
The diff coverage is 57.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #442      +/-   ##
==========================================
+ Coverage   66.64%   66.83%   +0.19%     
==========================================
  Files         124      127       +3     
  Lines        8852     8888      +36     
==========================================
+ Hits         5899     5940      +41     
+ Misses       2953     2948       -5     
Impacted Files Coverage Δ
boa/src/builtins/array/mod.rs 80.94% <0.00%> (ø)
boa/src/builtins/bigint/mod.rs 57.14% <0.00%> (+4.51%) ⬆️
boa/src/builtins/error/mod.rs 35.00% <0.00%> (ø)
boa/src/builtins/error/range.rs 35.00% <0.00%> (+7.00%) ⬆️
boa/src/exec/exception.rs 40.00% <40.00%> (ø)
boa/src/builtins/string/mod.rs 36.90% <50.00%> (ø)
boa/src/builtins/number/mod.rs 71.73% <60.00%> (+0.38%) ⬆️
boa/src/exec/operator/mod.rs 65.27% <66.66%> (-0.22%) ⬇️
boa/src/builtins/error/type.rs 70.00% <70.00%> (ø)
boa/src/builtins/function/mod.rs 73.18% <100.00%> (ø)
... and 8 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 145f0e3...7cab989. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Jun 2, 2020

Benchmark for df2416b

Click to view benchmark
Test PR Benchmark Master Benchmark %
Create Realm 461.3±27.20µs 449.0±41.18µs 103%
Expression (Lexer) 2.1±0.11µs 2.3±0.08µs 92%
Expression (Parser) 4.8±0.18µs 5.0±0.30µs 95%
Fibonacci (Execution) 3.0±0.09ms 2.8±0.12ms 110.00000000000001%
For loop (Execution) 502.5±20.60µs 474.2±24.77µs 106%
For loop (Lexer) 5.5±0.24µs 5.4±0.28µs 101%
For loop (Parser) 14.1±1.00µs 14.5±0.77µs 98%
Hello World (Lexer) 1022.3±55.94ns 1042.2±88.73ns 98%
Hello World (Parser) 2.3±0.13µs 2.4±0.11µs 95%
Symbols (Execution) 512.9±35.36µs 485.1±23.77µs 106%
undefined undefined 100%

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.

Check my comments, they are mostly for my understanding.

boa/src/builtins/number/mod.rs Outdated Show resolved Hide resolved
boa/src/exec/mod.rs Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Jun 2, 2020

Benchmark for eb10840

Click to view benchmark
Test PR Benchmark Master Benchmark %
Create Realm 449.6±14.85µs 442.6±17.99µs 102%
Expression (Lexer) 2.1±0.08µs 2.1±0.09µs 101%
Expression (Parser) 5.2±0.25µs 5.1±0.20µs 102%
Fibonacci (Execution) 2.7±0.10ms 2.6±0.06ms 102%
For loop (Execution) 475.0±30.60µs 454.5±7.37µs 105%
For loop (Lexer) 5.7±0.30µs 5.6±0.29µs 100%
For loop (Parser) 13.9±0.61µs 13.8±0.42µs 100%
Hello World (Lexer) 998.9±40.67ns 1001.5±25.96ns 100%
Hello World (Parser) 2.3±0.09µs 2.3±0.08µs 100%
Symbols (Execution) 473.3±14.85µs 475.1±23.91µs 100%
undefined undefined 100%

@HalidOdat HalidOdat requested a review from Razican June 2, 2020 12:25
@HalidOdat HalidOdat merged commit bb2b6f6 into master Jun 2, 2020
@HalidOdat HalidOdat deleted the feature/typeerror branch June 2, 2020 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants