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] - Fix remaining Promise bugs #2156

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions boa_engine/src/builtins/promise/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl BuiltIn for Promise {
None,
Attribute::CONFIGURABLE,
)
.method(Self::then, "then", 1)
.method(Self::then, "then", 2)
.method(Self::catch, "catch", 1)
.method(Self::finally, "finally", 1)
// <https://tc39.es/ecma262/#sec-promise.prototype-@@tostringtag>
Expand Down Expand Up @@ -399,14 +399,14 @@ impl Promise {
#[unsafe_ignore_trace]
already_called: Rc<Cell<bool>>,
index: usize,
values: GcCell<Vec<JsValue>>,
values: Gc<GcCell<Vec<JsValue>>>,
capability_resolve: JsFunction,
#[unsafe_ignore_trace]
remaining_elements_count: Rc<Cell<i32>>,
}

// 1. Let values be a new empty List.
let values = GcCell::new(Vec::new());
let values = Gc::new(GcCell::new(Vec::new()));

// 2. Let remainingElementsCount be the Record { [[Value]]: 1 }.
let remaining_elements_count = Rc::new(Cell::new(1));
Expand Down Expand Up @@ -439,7 +439,7 @@ impl Promise {
if remaining_elements_count.get() == 0 {
// 1. Let valuesArray be CreateArrayFromList(values).
let values_array = crate::builtins::Array::create_array_from_list(
values.into_inner(),
values.borrow().iter().cloned(),
context,
);

Expand Down Expand Up @@ -517,7 +517,7 @@ impl Promise {
if captures.remaining_elements_count.get() == 0 {
// a. Let valuesArray be CreateArrayFromList(values).
let values_array = crate::builtins::Array::create_array_from_list(
captures.values.clone().into_inner(),
captures.values.borrow().as_slice().iter().cloned(),
context,
);

Expand Down Expand Up @@ -640,14 +640,14 @@ impl Promise {
#[unsafe_ignore_trace]
already_called: Rc<Cell<bool>>,
index: usize,
values: GcCell<Vec<JsValue>>,
values: Gc<GcCell<Vec<JsValue>>>,
capability: JsFunction,
#[unsafe_ignore_trace]
remaining_elements: Rc<Cell<i32>>,
}

// 1. Let values be a new empty List.
let values = GcCell::new(Vec::new());
let values = Gc::new(GcCell::new(Vec::new()));

// 2. Let remainingElementsCount be the Record { [[Value]]: 1 }.
let remaining_elements_count = Rc::new(Cell::new(1));
Expand Down Expand Up @@ -680,7 +680,7 @@ impl Promise {
if remaining_elements_count.get() == 0 {
// 1. Let valuesArray be CreateArrayFromList(values).
let values_array = crate::builtins::Array::create_array_from_list(
values.into_inner(),
values.borrow().as_slice().iter().cloned(),
context,
);

Expand Down Expand Up @@ -772,7 +772,7 @@ impl Promise {
if captures.remaining_elements.get() == 0 {
// a. Let valuesArray be CreateArrayFromList(values).
let values_array = Array::create_array_from_list(
captures.values.clone().into_inner(),
captures.values.borrow().as_slice().iter().cloned(),
context,
);

Expand Down Expand Up @@ -852,7 +852,7 @@ impl Promise {
if captures.remaining_elements.get() == 0 {
// a. Let valuesArray be CreateArrayFromList(values).
let values_array = Array::create_array_from_list(
captures.values.clone().into_inner(),
captures.values.borrow().as_slice().iter().cloned(),
context,
);

Expand All @@ -871,7 +871,7 @@ impl Promise {
already_called: Rc::new(Cell::new(false)),
index,
values: values.clone(),
capability: result_capability.reject.clone(),
capability: result_capability.resolve.clone(),
remaining_elements: remaining_elements_count.clone(),
},
)
Expand Down Expand Up @@ -971,14 +971,14 @@ impl Promise {
#[unsafe_ignore_trace]
already_called: Rc<Cell<bool>>,
index: usize,
errors: GcCell<Vec<JsValue>>,
errors: Gc<GcCell<Vec<JsValue>>>,
capability_reject: JsFunction,
#[unsafe_ignore_trace]
remaining_elements_count: Rc<Cell<i32>>,
}

// 1. Let errors be a new empty List.
let errors = GcCell::new(Vec::new());
let errors = Gc::new(GcCell::new(Vec::new()));

// 2. Let remainingElementsCount be the Record { [[Value]]: 1 }.
let remaining_elements_count = Rc::new(Cell::new(1));
Expand Down Expand Up @@ -1028,7 +1028,7 @@ impl Promise {
.enumerable(false)
.writable(true)
.value(Array::create_array_from_list(
errors.into_inner(),
errors.borrow().as_slice().iter().cloned(),
context,
)),
context,
Expand Down Expand Up @@ -1123,7 +1123,7 @@ impl Promise {
.enumerable(false)
.writable(true)
.value(Array::create_array_from_list(
captures.errors.clone().into_inner(),
captures.errors.borrow().as_slice().iter().cloned(),
context,
)),
context,
Expand Down