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 RegExp constructor return value when pattern is a regexp #2880

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
9 changes: 8 additions & 1 deletion boa_engine/src/builtins/regexp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,20 @@ impl BuiltInConstructor for RegExp {
// 3. Else, let newTarget be NewTarget.
if new_target.is_undefined() {
// a. Let newTarget be the active function object.
let new_target = context
.vm
.active_function
.clone()
.map_or(JsValue::undefined(), JsValue::new);

// b. If patternIsRegExp is true and flags is undefined, then
if let Some(pattern) = pattern_is_regexp {
if flags.is_undefined() {
// i. Let patternConstructor be ? Get(pattern, "constructor").
let pattern_constructor = pattern.get(CONSTRUCTOR, context)?;

// ii. If SameValue(newTarget, patternConstructor) is true, return pattern.
if JsValue::same_value(new_target, &pattern_constructor) {
if JsValue::same_value(&new_target, &pattern_constructor) {
return Ok(pattern.clone().into());
}
}
Expand Down