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

More panic fixes #1050

Merged
merged 2 commits into from
Jan 9, 2021
Merged
Show file tree
Hide file tree
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
10 changes: 4 additions & 6 deletions boa/src/builtins/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,8 @@ impl Map {
_ => (args[0].clone(), args[1].clone()),
};

let size = if let Value::Object(ref object) = this {
let mut object = object.borrow_mut();
if let Some(map) = object.as_map_mut() {
let size = if let Some(object) = this.as_object() {
if let Some(map) = object.borrow_mut().as_map_mut() {
map.insert(key, value);
map.len()
} else {
Expand Down Expand Up @@ -218,9 +217,8 @@ impl Map {
_ => &args[0],
};

let (deleted, size) = if let Value::Object(ref object) = this {
let mut object = object.borrow_mut();
if let Some(map) = object.as_map_mut() {
let (deleted, size) = if let Some(object) = this.as_object() {
if let Some(map) = object.borrow_mut().as_map_mut() {
let deleted = map.remove(key).is_some();
(deleted, map.len())
} else {
Expand Down
9 changes: 7 additions & 2 deletions boa/src/builtins/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,8 @@ impl String {
}
(Some('<'), _) => {
// $<
todo!("named capture groups")
// TODO: named capture groups
result.push_str("$<");
}
_ => {
// $?, ? is none of the above
Expand Down Expand Up @@ -845,7 +846,11 @@ impl String {
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match
/// [regex]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
pub(crate) fn r#match(this: &Value, args: &[Value], context: &mut Context) -> Result<Value> {
let re = RegExp::constructor(&Value::from(Object::default()), &[args[0].clone()], context)?;
let re = RegExp::constructor(
&Value::from(Object::default()),
&[args.get(0).cloned().unwrap_or_default()],
context,
)?;
RegExp::r#match(&re, this.to_string(context)?, context)
}

Expand Down