Skip to content

Commit

Permalink
Add primitive promotion for method calls on GetField (#1085)
Browse files Browse the repository at this point in the history
  • Loading branch information
RageKnify authored and Razican committed May 22, 2021
1 parent 3b61e50 commit 6340dc5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 4 additions & 1 deletion boa/src/syntax/ast/node/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ impl Executable for Call {
)
}
Node::GetField(ref get_field) => {
let obj = get_field.obj().run(context)?;
let mut obj = get_field.obj().run(context)?;
if obj.get_type() != Type::Object {
obj = Value::Object(obj.to_object(context)?);
}
let field = get_field.field().run(context)?;
(
obj.clone(),
Expand Down
1 change: 0 additions & 1 deletion boa/src/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ impl Value {

/// Resolve the property in the object and get its value, or undefined if this is not an object or the field doesn't exist
/// get_field receives a Property from get_prop(). It should then return the `[[Get]]` result value if that's set, otherwise fall back to `[[Value]]`
/// TODO: this function should use the get Value if its set
pub fn get_field<K>(&self, key: K, context: &mut Context) -> Result<Self>
where
K: Into<PropertyKey>,
Expand Down

0 comments on commit 6340dc5

Please sign in to comment.