-
-
Notifications
You must be signed in to change notification settings - Fork 400
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
Attributes created by JSON.parse cannot be modified #434
Comments
The bug is here. Property::default().value(Value::from(json.clone())).writable(true).configurable(true).enumerable(true), Doing this should fix it :) |
I can take this. |
Looks like this was partially addressed in #410 . I'm trying to figure out a good way to test the enumerable portion. |
Assuming |
Go ahead! :) |
@HalidOdat -- I'm trying to test that the properties are enumerable by using the boa/boa/src/builtins/value/mod.rs Line 702 in bb2b6f6
and boa/boa/src/builtins/object/mod.rs Lines 339 to 351 in bb2b6f6
What would be the best way to grab the Object.prototype so that it can be added to those objects?
|
Hmmm. For this we need to take in an Interpreter (context) in This issue can be easily tested with: var a = JSON.parse('{"x":0}');
a.x=2;
a.x and asserting that |
@HalidOdat doesn’t asserting that the value changes only assert that it is writeable? As the bug was written, it is technically no longer a bug. However, the properties are not enumerated so I figured I’d just use this issue for that problem. |
I see. Even if we implement |
Agreed. |
@HalidOdat @Razican -- As was mentioned earlier in this thread, I'm using /// Returns a new empty object
pub fn new_object(global: Option<&Value>) -> Self {
let _timer = BoaProfiler::global().start_event("new_object", "value");
if let Some(global) = global {
let object_prototype = global.get_field("Object").get_field(PROTOTYPE);
println!("object prototype: {:?}", object_prototype);
let object = Object::create(object_prototype);
println!("new object: {:?}", object);
Self::object(object)
} else {
Self::object(Object::default())
}
}
Are my expectations on what should be happening off here? I've pushed my branch up if that would be easier than interpreting what I've stated above. You can find it here |
Were not losing the object prototype but were not displaying it, the debug printer The prototype property Hope this helps :) |
It helps explain why I'm not seeing it in the print statements 😄; however, I'm still not seeing the |
Hmmm. I think I know why this is happening because the order of the builtins initialization is not right! here |
This doesn't quite seem to do the trick. Everything is added to that global object all at once after everything has been initialized. Thus, when
|
#502 should fix this bug :) |
JSON.parse seems to create object whose attributes cannot be modified (but can be deleted).
Steps To Reproduce
Checkout current master (87aea64)
start cli:
./target/debug/boa
Enter
The value
a.x
is still0
instead of expected2
.Build environment (please complete the following information):
The text was updated successfully, but these errors were encountered: