purescript-json icon indicating copy to clipboard operation
purescript-json copied to clipboard

Object Insert Issue

Open farzadbekran opened this issue 4 months ago • 1 comments

The documentation for JSON.Object.insert states that it will overwrite values for the existing keys, but it is not overwriting, you have to delete the key manually before inserting an existing key.

I think the issue is that the underlying method used (assign) does not actually overwrite existing keys:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign

farzadbekran avatar Oct 25 '25 12:10 farzadbekran

Definitely a bug :+1:, thanks!

Probably should be implemented as Object.assign({}, obj, { [k]: v }); instead, or maybe by property assignment after cloning the object.

garyb avatar Oct 25 '25 20:10 garyb