Boa: Objects that are created with `ValuData::from_json()` do not contain `prototype` instance (`__proto__`).

Created on 3 Jun 2020  路  3Comments  路  Source: boa-dev/boa

Describe the bug

Objects that are created with ValuData::from_json() do not contain prototype instance (__proto__).

To Reproduce

JSON.parse("{x: 0}")

Actual behavior

{
    x: 0,
    extensible: true
}

Expected behavior

{
    x: 0,
    extensible: true,
    __proto__: {
        ...  
    }
}

Fixed object prototypes:

  • [x] Object prototype (#462)
  • [x] Array prototype (#476)

Build environment (please complete the following information):

  • OS: Manjaro Linux
  • Target triple: x86_64-unknown-linux-gnu
  • Rustc version: rustc 1.43.1 (8d69840ab 2020-05-04)

Additional context

For this to be fixed we need ValuData::from_json() to take in an Interpreter (context) get the prototype and construct the Object.

bug builtins

All 3 comments

@HalidOdat it looks like in order to get the Interpreter to ValueData::from_json() we would need to have access to the Interpreter in this conversion: https://github.com/boa-dev/boa/blob/bb2b6f638cba59269694d44424d16c9a5ede6a81/boa/src/builtins/value/conversions.rs#L191-L195
But, from my understanding, that is not possible. It seems that this conversion implementing From<JSONValue> for Value just have to go away? Is that correct, or is there something I'm missing? I'm pretty new to Rust.

But, from my understanding, that is not possible. It seems that this conversion implementing From<JSONValue> for Value just have to go away? Is that correct, or is there something I'm missing? I'm pretty new to Rust.

That's right. We should remove it and use ValueData::from_json() with it taking an Interpreter.

I am working on this to get myself going on some other issues assigned to me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Razican picture Razican  路  5Comments

attliaLin picture attliaLin  路  3Comments

Razican picture Razican  路  4Comments

IovoslavIovchev picture IovoslavIovchev  路  4Comments

HalidOdat picture HalidOdat  路  3Comments