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:
Object prototype (#462) Array prototype (#476)Build environment (please complete the following information):
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.
@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 Valuejust 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.