This Pull Request implements optional chains.
Example:
```Javascript
const adventurer = {
name: 'Alice',
cat: {
name: 'Dinah'
}
};
console.log(adventurer.cat?.name); // Dinah
console.log(adventurer.dog?.name); // undefined
```
Since I needed to implement `Opcode::RotateLeft`, and #2378 had an implementation for `Opcode::RotateRight`, I took the opportunity to integrate both ops into this PR (big thanks to @HalidOdat for the original implementation!).
This PR almost has 100% conformance for the `optional-chaining` test suite. However, there's this one [test](85373b4ce1/test/language/expressions/optional-chaining/member-expression.js) that can't be solved until we properly set function names for function expressions in object and class definitions.
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel necessary.
--->
This Pull Request is related to #2098.
It changes the following:
- Implements a wrapper for the `Generator` built-in object
- Adds to some of the documentation across the builtin wrappers with the goal of trying to clean up the documentation by making it a bit more consistent [on boa's docs](https://boa-dev.github.io/boa/doc/boa_engine/object/builtins/index.html)
This Pull Request allows collisions of var declarations with already existing lexical bindings if the `eval` call is strict or occurs within strict code. In short, it allows:
```Javascript
{
let x;
{
eval('"use strict"; var x;');
}
}
```
and
```Javascript
"use strict";
{
let x;
{
eval('var x;');
}
}
```
This is valid since in strict code all `eval` calls get their own function environment, making it impossible to declare a new var in the outer function environment. This change also skips poisoning environments on strict code, because `eval` cannot add new declarations for the current environment in that situation.
This Pull Request implements member accessors in `for ... in` and `for ... of` loops. This unlocks patterns like:
```Javascript
let obj = {a: 0, b: 1};
for (obj.a of [1,2,3]) {
}
console.log(obj.a) // 3
```
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.145 to 1.0.147.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/serde-rs/serde/releases">serde's releases</a>.</em></p>
<blockquote>
<h2>v1.0.147</h2>
<ul>
<li>Add <code>serde:🇩🇪:value::EnumAccessDeserializer</code> which transforms an <code>EnumAccess</code> into a <code>Deserializer</code> (<a href="https://github-redirect.dependabot.com/serde-rs/serde/issues/2305">#2305</a>)</li>
</ul>
<h2>v1.0.146</h2>
<ul>
<li>Allow internally tagged newtype variant to contain unit (<a href="https://github-redirect.dependabot.com/serde-rs/serde/issues/2303">#2303</a>, thanks <a href="https://github.com/tage64"><code>@tage64</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="f41509261e"><code>f415092</code></a> Release 1.0.147</li>
<li><a href="6d009711a2"><code>6d00971</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/serde-rs/serde/issues/2305">#2305</a> from serde-rs/enumaccessdeserializer</li>
<li><a href="354b48fd40"><code>354b48f</code></a> Add EnumAccessDeserializer to turn EnumAccess into a Deserializer</li>
<li><a href="3fd8e52f0c"><code>3fd8e52</code></a> Release 1.0.146</li>
<li><a href="142dce0d3d"><code>142dce0</code></a> Touch up PR 2303</li>
<li><a href="6aed101630"><code>6aed101</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/serde-rs/serde/issues/2303">#2303</a> from tage64/master</li>
<li><a href="e2ccfd9ea7"><code>e2ccfd9</code></a> Remove bad deserialization from sequence to internally tagged newtype variant...</li>
<li><a href="a07d794f74"><code>a07d794</code></a> Update test_suite/tests/test_annotations.rs</li>
<li><a href="90d28fc314"><code>90d28fc</code></a> Serialize and deserialize a tagged newtype variant over unit () as if it was ...</li>
<li><a href="55cf0ac51a"><code>55cf0ac</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/serde-rs/serde/issues/2297">#2297</a> from serde-rs/output</li>
<li>Additional commits viewable in <a href="https://github.com/serde-rs/serde/compare/v1.0.145...v1.0.147">compare view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=serde&package-manager=cargo&previous-version=1.0.145&new-version=1.0.147)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
</details>
In most cases, the `ToInternedString` was just calling `self.to_indented_string(interner, 0)`. This avoids all this duplicate code by adding a new trait, `ToIndentedString`. Any type implementing that automatically implements `ToInternedString`.
I have also added a bunch of `#[inline]` in one-liners, and some one-line documentations for some functions.
I have noticed that we also use `contains()` and `contains_arguments()` a lot. Would it make sense to create traits for this?
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel necessary.
--->
Hi!
This isn't really related to a pull request that I know of. I was trying to better wrap my head around Boa's VM and thought I'd break it apart so that the file wasn't 2500+ lines. I figured I'd submit it as a draft and get feedback/see if anyone was interested in it. The way the modules were broken apart was primarily based off the opcode name (`GetFunction` & `GetFunctionAsync` -> `./get/function.rs`).
It changes the following:
- Adds an `Operation` trait to opcode/mod.rs
- Implements `Operation` for each Opcode variant, moving the executable instruction code from `vm/mod.rs` to the respective module
Co-authored-by: raskad <32105367+raskad@users.noreply.github.com>
This Pull Request changes the following:
- Fix error in `Proxy` set implementation
After this all other failing `Proxy` tests fail because of us missing the `with` implementation.
Co-authored-by: RageKnify <RageKnify@gmail.com>
This Pull Request changes the following:
- Implements the `LabelledStatement` Parse node.
- Removes `label` from all label-able items (switch, blocks and loop statements).
- Adjusts parsing to the new AST.
#2295 isn't fixed by this, but with this change it should be easier to fix.
This Pull Request fixes a small error in the documentation of `Context::register_global_function()` method, and a few clippy errors we were getting in the tests.
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.86 to 1.0.87.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/serde-rs/json/releases">serde_json's releases</a>.</em></p>
<blockquote>
<h2>v1.0.87</h2>
<ul>
<li>Add <code>write_i128</code> and <code>write_u128</code> methods to <code>serde_json::Formatter</code> to control the formatting of 128-bit integers (<a href="https://github-redirect.dependabot.com/serde-rs/json/issues/940">#940</a>, thanks <a href="https://github.com/Lucretiel"><code>@Lucretiel</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="993e7a6eea"><code>993e7a6</code></a> Release 1.0.87</li>
<li><a href="31070349af"><code>3107034</code></a> Eliminate needless 'tri!' from Serializer impl</li>
<li><a href="46c9778ce1"><code>46c9778</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/serde-rs/json/issues/942">#942</a> from serde-rs/integer128</li>
<li><a href="37e76e0f85"><code>37e76e0</code></a> Assume serde_if_integer128 is true</li>
<li><a href="ec0456ad7b"><code>ec0456a</code></a> Use existing macros to implement 128-bit From impls</li>
<li><a href="c183125e04"><code>c183125</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/serde-rs/json/issues/941">#941</a> from serde-rs/alloc</li>
<li><a href="ab0f884fb6"><code>ab0f884</code></a> Delete 1.36+ caveat from descriptions of alloc feature</li>
<li><a href="486598bbef"><code>486598b</code></a> Merge pull request 940 from Lucretiel/int128</li>
<li><a href="84d6d95e01"><code>84d6d95</code></a> Add direct support for i128 and u128 via itoa</li>
<li>See full diff in <a href="https://github.com/serde-rs/json/compare/v1.0.86...v1.0.87">compare view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=serde_json&package-manager=cargo&previous-version=1.0.86&new-version=1.0.87)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
</details>
This is an experiment that tries to migrate the codebase from eager `Error` objects to lazy ones.
In short words, this redefines `JsResult = Result<JsValue, JsError>`, where `JsError` is a brand new type that stores only the essential part of an error type, and only transforms those errors to `JsObject`s on demand (when having to pass them as arguments to functions or store them inside async/generators).
This change is pretty big, because it unblocks a LOT of code from having to take a `&mut Context` on each call. It also paves the road for possibly making `JsError` a proper variant of `JsValue`, which can be a pretty big optimization for try/catch.
A downside of this is that it exposes some brand new error types to our public API. However, we can now implement `Error` on `JsError`, making our `JsResult` type a bit more inline with Rust's best practices.
~Will mark this as draft, since it's missing some documentation and a lot of examples, but~ it's pretty much feature complete. As always, any comments about the design are very much appreciated!
Note: Since there are a lot of changes which are essentially just rewriting `context.throw` to `JsNativeError::%type%`, I'll leave an "index" of the most important changes here:
- [boa_engine/src/error.rs](https://github.com/boa-dev/boa/pull/2283/files#diff-f15f2715655440626eefda5c46193d29856f4949ad37380c129a8debc6b82f26)
- [boa_engine/src/builtins/error/mod.rs](https://github.com/boa-dev/boa/pull/2283/files#diff-3eb1e4b4b5c7210eb98192a5277f5a239148423c6b970c4ae05d1b267f8f1084)
- [boa_tester/src/exec/mod.rs](https://github.com/boa-dev/boa/pull/2283/files#diff-fc3d7ad7b5e64574258c9febbe56171f3309b74e0c8da35238a76002f3ee34d9)
This Pull Request fixes#1371. And yeah, the number of file changes is real...
It changes the following:
- Split the ast `Node` into `Statement` and `Expression`.
- Rewrite the parser and bytecompiler to conform to this change.
- Refactor some ast nodes into reusable structures.
- Rewrite `contains_arguments` and `contains` to ease the transition into a future ast visitor.
List of things that were apparently fixed by this refactor?:
- Implement read-assign operation for private accessors (e.g. `this.#field ||= 5`).
- `var await` declaration now allowed outside `async` functions and inside functions nested in async functions.
- Reject redeclarations of variables declared in the init list of a for loop.
Still missing some documentation adjustments, will try to do it ASAP.
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel necessary.
--->
This Pull Request is related to #2098.
It changes the following:
- Implements `JsRegExp`
- Adds a brief `JsRegExp` example under `boa_examples`
I think it's time to address the elephant in the room.
This Pull Request will (hopefully!) solve part of #736.
This is a complete rewrite of `JsString`, but instead of storing `u8` bytes it stores `u16` words. The `encode!` macro (renamed to `utf16!` for simplicity) from the `const-utf16` crate allows us to create UTF-16 encoded arrays at compilation time. `JsString` implements `Deref<Target=[u16]>` to unlock the slice methods and possibly make some manipulations easier. However, we would need to create our own library of utilities for `JsString`.
This Pull Request closes#2080.
It moves all implementors of the `JsObjectType` trait into their own `js_object` module.
This should simplify documentation and by doing a `pub(crate)` export in `object` little to no imports within the crate need to be changed, simplifying the usage of this module within the boa_engine crate.
Documentation within the `object` module has been updated to reflect this change and in a way that it is shown on the home page of the documentation.
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel necessary.
--->
This Pull Request is related to #2098 .
It changes the following:
- Implements a wrapper for `DataView`
- Adds an example of `JsDataView` to the `JsArrayBuffer` example file under boa_examples
Co-authored-by: jedel1043 <jedel0124@gmail.com>
This Pull Request switches our codebase to the brand new [workspace inherited keys](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-package-table), which allows us to define common package options that are usable within each crate's Cargo.toml file.
It also allows to share dependency versions between crates, but I defined only shared versions for our workspace members. It would be a good follow-up to lift all the shared dependencies between crates into the global Cargo.toml.
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.144 to 1.0.145.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/serde-rs/serde/releases">serde's releases</a>.</em></p>
<blockquote>
<h2>v1.0.145</h2>
<ul>
<li>Allow RefCell<T>, Mutex<T>, and RwLock<T> to be serialized regardless of whether T is <code>Sized</code> (<a href="https://github-redirect.dependabot.com/serde-rs/serde/issues/2282">#2282</a>, thanks <a href="https://github.com/ChayimFriedman2"><code>@ChayimFriedman2</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="8c036ee5a3"><code>8c036ee</code></a> Release 1.0.145</li>
<li><a href="d99009f3c6"><code>d99009f</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/serde-rs/serde/issues/2282">#2282</a> from ChayimFriedman2/sized-mutex-refcell-rwlock</li>
<li><a href="be3c37eb8b"><code>be3c37e</code></a> Serialize unsized <code>RefCell</code>, <code>Mutex</code> and <code>RwLock</code></li>
<li><a href="f0346ae054"><code>f0346ae</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/serde-rs/serde/issues/2281">#2281</a> from dtolnay/try</li>
<li><a href="fa6ce42056"><code>fa6ce42</code></a> Redefine 'try' macro to omit From::from error conversion</li>
<li><a href="a9320db6f9"><code>a9320db</code></a> Consistently avoid '?' throughout serde crate</li>
<li><a href="d208762c81"><code>d208762</code></a> Command-line ignore let_underscore_drop clippy lint</li>
<li><a href="5386897d24"><code>5386897</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/serde-rs/serde/issues/2273">#2273</a> from sashashura/patch-1</li>
<li><a href="68eb59df0c"><code>68eb59d</code></a> Update ci.yml</li>
<li><a href="a7f4551669"><code>a7f4551</code></a> Add dev-dependencies keyword for serde_test</li>
<li>See full diff in <a href="https://github.com/serde-rs/serde/compare/v1.0.144...v1.0.145">compare view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=serde&package-manager=cargo&previous-version=1.0.144&new-version=1.0.145)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
</details>
This Pull Request overrides #2288.
It changes the following:
- Updates dependencies to use Unicode 15
- Updates the boa_unicode crate to use Unicode 15
It's still waiting on the unicode-general-category 0.6 release, which was tagged 3 days ago: 15e7e3182f
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.14.0 to 1.15.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/matklad/once_cell/blob/master/CHANGELOG.md">once_cell's changelog</a>.</em></p>
<blockquote>
<h2>1.15.0</h2>
<ul>
<li>Increase minimal supported Rust version to 1.56.0.</li>
<li>Implement <code>UnwindSafe</code> even if the <code>std</code> feature is disabled.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="97edd07e0a"><code>97edd07</code></a> Merge <a href="https://github-redirect.dependabot.com/matklad/once_cell/issues/200">#200</a></li>
<li><a href="f5264bbaf1"><code>f5264bb</code></a> release 1.15.0</li>
<li><a href="a0aeb9b378"><code>a0aeb9b</code></a> Merge <a href="https://github-redirect.dependabot.com/matklad/once_cell/issues/199">#199</a></li>
<li><a href="1d8a90d231"><code>1d8a90d</code></a> fix token name</li>
<li><a href="5ca60af311"><code>5ca60af</code></a> Merge <a href="https://github-redirect.dependabot.com/matklad/once_cell/issues/198">#198</a></li>
<li><a href="99c67b7906"><code>99c67b7</code></a> 1.15.0</li>
<li><a href="b68bee9c56"><code>b68bee9</code></a> edition 2021</li>
<li><a href="8e47e43a49"><code>8e47e43</code></a> always implement unwind safe</li>
<li><a href="8ec240e9db"><code>8ec240e</code></a> MSRV is 1.56</li>
<li><a href="2487d34593"><code>2487d34</code></a> Merge <a href="https://github-redirect.dependabot.com/matklad/once_cell/issues/197">#197</a></li>
<li>Additional commits viewable in <a href="https://github.com/matklad/once_cell/compare/v1.14.0...v1.15.0">compare view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=once_cell&package-manager=cargo&previous-version=1.14.0&new-version=1.15.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
</details>
This Pull Request fixes/closes #1987.
It changes the following:
- Add a prototype to the global object.
- Implement `__get_prototype_of__`, `__set_prototype_of__`, `__get_own_property__`, and `__own_property_keys__` for the global object
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel neccesary.
--->
This Pull Request fixes [x-after-break-to-label](dc1dc28aa4/test/language/block-scope/leave/x-after-break-to-label.js)
### Example
```js
{
let x = 2;
L: {
let x = 3;
console.log(x === 3);
break L;
console.log(false);
}
console.log(x === 2);
}
```
### Previously
> Uncaught "SyntaxError": "Cannot use the undeclared label 'L'"
### Now
> true <br> true
### What did I do
1. add `lable` to `Node::Block`
2. push labelled-block's `control info` to `jump_info` list
3. pop it before `Opcode::PopEnvironment`
Co-authored-by: creampnx_x <2270436024@qq.com>
This Pull Request closes#894.
It changes the following:
- Adds the `encodeURI()`, `decodeURI()`, `encodeURIComponent()` and `decodeURIComponent()` functions
- Passes all the tests except for those depending on #1987 or on the comment below.
Things to discuss:
- I'm unable to find in the spec information regarding the only failing tests, which relate to [this](f1870753fa/test/built-ins/encodeURI/S15.1.3.3_A1.1_T2.js):
> If string.charAt(k) in [0xDC00 - 0xDFFF], throw URIError
Let me know your thoughts :)
Co-authored-by: raskad <32105367+raskad@users.noreply.github.com>
This Pull Request changes the following:
- Implement [Async-from-Sync Iterator Objects](https://tc39.es/ecma262/#sec-async-from-sync-iterator-objects)
- Give the proper `async` hint to `GetIterator` when executing a delegate yield expression in an async generator function
This Pull Request fixes/closes #2148.
It changes the following:
- When we start an assignment expression, the `/` token must be a regular expression literal. The division can only occur between expressions after the assignment operator.
- Added tests for the new behaviour, taken from #2177
This overrides #2177
This Pull Request fixes a potential overflow when trying to convert a `u64` into a `usize` and then trying to create a byte data block.
Related to this, we seem to be using a `u64` and `i64` as a general approach for an "integer", but ECMAScript doesn't have bounds for them, so they could be as big as infinite. Should we use `u128` and `i128` to have a bigger range?
This would add a performance penalty, though, and we don't have 128-bit platforms usually, so the benefit would probably be minimal, at least when trying to allocate.
Updates the requirements on [criterion](https://github.com/bheisler/criterion.rs) to permit the latest version.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/bheisler/criterion.rs/blob/master/CHANGELOG.md">criterion's changelog</a>.</em></p>
<blockquote>
<h2>[0.4.0] - 2022-09-10</h2>
<h3>Removed</h3>
<ul>
<li>The <code>Criterion::can_plot</code> function has been removed.</li>
<li>The <code>Criterion::bench_function_over_inputs</code> function has been removed.</li>
<li>The <code>Criterion::bench_functions</code> function has been removed.</li>
<li>The <code>Criterion::bench</code> function has been removed.</li>
</ul>
<h3>Changed</h3>
<ul>
<li>HTML report hidden behind non-default feature flag: 'html_reports'</li>
<li>Standalone support (ie without cargo-criterion) feature flag: 'cargo_bench_support'</li>
<li>MSRV bumped to 1.57</li>
<li><code>rayon</code> and <code>plotters</code> are optional (and default) dependencies.</li>
<li>Status messages ('warming up', 'analyzing', etc) are printed to stderr, benchmark results are printed to stdout.</li>
<li>Accept subsecond durations for <code>--warm-up-time</code>, <code>--measurement-time</code> and <code>--profile-time</code>.</li>
<li>Replaced serde_cbor with ciborium because the former is no longer maintained.</li>
<li>Upgrade clap to v3 and regex to v1.5.</li>
</ul>
<h3>Added</h3>
<ul>
<li>A <code>--discard-baseline</code> flag for discarding rather than saving benchmark results.</li>
<li>Formal support for benchmarking code compiled to web-assembly.</li>
<li>A <code>--quiet</code> flag for printing just a single line per benchmark.</li>
<li>A <code>Throughput::BytesDecimal</code> option for measuring throughput in bytes but printing them using
decimal units like kilobytes instead of binary units like kibibytes.</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>When using <code>bench_with_input</code>, the input parameter will now be passed through <code>black_box</code> before
passing it to the benchmark.</li>
</ul>
<h2>[0.3.6] - 2022-07-06</h2>
<h3>Changed</h3>
<ul>
<li>MSRV bumped to 1.49</li>
<li>Symbol for microseconds changed from ASCII 'us' to unicode 'µs'</li>
<li>Documentation fixes</li>
<li>Clippy fixes</li>
</ul>
<h2>[0.3.5] - 2021-07-26</h2>
<h3>Fixed</h3>
<ul>
<li>Corrected <code>Criterion.toml</code> in the book.</li>
<li>Corrected configuration typo in the book.</li>
</ul>
<h3>Changed</h3>
<ul>
<li>Bump plotters dependency to always include a bug-fix.</li>
<li>MSRV bumped to 1.46.</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="5e27b692a4"><code>5e27b69</code></a> Merge branch 'version-0.4'</li>
<li><a href="4d6d69a9f5"><code>4d6d69a</code></a> Increment version numbers.</li>
<li><a href="935c6327e1"><code>935c632</code></a> Add Throughput::BytesDecimal. Fixes <a href="https://github-redirect.dependabot.com/bheisler/criterion.rs/issues/581">#581</a>.</li>
<li><a href="f82ce59d71"><code>f82ce59</code></a> Remove critcmp code (it belongs in cargo-criterion) (<a href="https://github-redirect.dependabot.com/bheisler/criterion.rs/issues/610">#610</a>)</li>
<li><a href="a18d0800a9"><code>a18d080</code></a> Merge branch 'master' into version-0.4</li>
<li><a href="f9c6b8d1c0"><code>f9c6b8d</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/bheisler/criterion.rs/issues/608">#608</a> from Cryptex-github/patch-1</li>
<li><a href="8d0224e9f1"><code>8d0224e</code></a> Fix html report path</li>
<li><a href="2934163518"><code>2934163</code></a> Add missing black_box for bench_with_input parameters. Fixes 566.</li>
<li><a href="dfd7b6532b"><code>dfd7b65</code></a> Add duplicated benchmark ID to assertion message.</li>
<li><a href="ce8259e69f"><code>ce8259e</code></a> Bump criterion-plot version number.</li>
<li>Additional commits viewable in <a href="https://github.com/bheisler/criterion.rs/compare/0.3.5...0.4.0">compare view</a></li>
</ul>
</details>
<br />
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
</details>
This PR fixes a case where a forward slash is located in a regex class: `let regex = /[/]/;`. In this case, the forward slash should not close the regex literal.
This fixes `test/built-ins/RegExp/regexp-class-chars.js`
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel neccesary.
--->
This Pull Request fixes: 79e3bc5176/test/language/computed-property-names/object/method/super.js
This PR solves the bug of using the `super` keyword in the method attribute of object. When the environment is `None`, the `vm` gets the top element of `vm.stack` as `this`, such as:
```js
var a = {
f() {
return super.m();
}
};
var b = {
m() {
retrun "super";
}
};
Object.setPrototypeOf(a, b);
a.f(); // the top of stack is `a`
let f = a.f;
f(); // the top of stack is `global_this`, so `super` cannot be used
```
### Can be improved
What I think is that when I use `object.method()`, the engine should bind `this_object` to the `environment`, instead of using `vm.stack.last()...`.
### TODOS
1. `super` need to look for properties all the way to the end.
Co-authored-by: creampnx_x <2270436024@qq.com>
This PR fixes#2275
There are keywords that are allowed as identifiers.
https://tc39.es/ecma262/#sec-keywords-and-reserved-words
> Those that are always allowed as identifiers, but also appear as keywords within certain syntactic productions, at places where Identifier is not allowed: as, async, from, get, meta, of, set, and target.
This PR adds test cases for them, and fixes some cases such as
`class A { set(a, b) { } }`
`function of() { }`
`let obj = {async: true}`
`async()`
There can be a line terminator in the middle of variable declaration statement. For example,
```js
var a
, b;
```
In this case, we should not insert semicolon automatically.
This fixes:
- test262/test/language/asi/S7.9_A7_T8.js
- test262/test/language/asi/S7.9_A7_T9.js
Skip `to_string` for integer type primitives in `to_property_key`. It's unnecessary to convert the integer value to string and convert back to `Index(u32)` type.
In this example code, it improves around 10% of runtime.
```js
let arr = [1,2,3,4,5];
for (let i = 0; i < 10000000; i++) {
arr[0] = 123;
}
```
Before: 6.24s
After: 5.38s