Comments (6)
We observed invariant failures in JSC's prototype implementation, and we found that V8 crashes with the above example with --harmony-json-parse-with-source
from proposal-json-parse-with-source.
This looks like ultimately the same root cause as #35, which was also noticed during V8's implementation.
@gibson042 @mathiasbynens Needless to say this and #35 is a hard blocker for shipping.
from proposal-json-parse-with-source.
Nice find, @Constellation! This is a counterexample to our claim that bottom-up invocation renders moot the concern about divergence between live values and the source text from which they are derived, and will require a normative change to fix. I'll make a PR to take a shallow snapshot of arrays and other objects and suppress source
in the context passed to the reviver for entries that have diverged and raise it for approval at the next TC39 plenary. We'll also want to cover this with test cases:
- [array and plain object] overwrite of not-yet-processed entry should result in absence of
source
for that entry- primitive to non-primitive
- non-primitive to primitive
- non-primitive to a clone (same date but different identity)
- primitive to a different primitive
- [array and plain object] overwrite and restoration of not-yet-processed entry should preserve
source
for that entry- primitive
- non-primitive
- [array] splicing out an item should result in absence of
source
from the affected index forward- ...but restoring items at their original index should preserve
source
- ...but restoring items at their original index should preserve
from proposal-json-parse-with-source.
What about deletion and recreation of an already processed object property? Values would be the same but order wouldn't.
from proposal-json-parse-with-source.
Would it be web compatible to use the snapshot of objects and arrays for the entries passed to the reviver, and ignore mutations past snapshot time?
I mean which legitimate code mutates the object through the reviver?
from proposal-json-parse-with-source.
What about deletion and recreation of an already processed object property? Values would be the same but order wouldn't.
My plan is to preserve source
in that case:
const reorderedSource = JSON.parse(
'{ "foo": 0, "bar": 1, "baz": 2 }',
function reviver(key, value, {source}) {
if (key === "foo") {
// Reposition the "bar" property.
const barVal = this.bar;
delete this.bar;
this.bar = barVal;
}
return key ? source : value;
},
);
assert.strictEqual(reorderedSource.bar, "1");
Would it be web compatible to use the snapshot of objects and arrays for the entries passed to the reviver, and ignore mutations past snapshot time?
I mean which legitimate code mutates the object through the reviver?
I don't think it would be (as evidenced in part by these two issues), and at any rate such a change is out of scope for this proposal.
from proposal-json-parse-with-source.
Related Issues (20)
- Expose position and/or input of source text? HOT 12
- Supply an array of keys for understanding value context? HOT 3
- Extend this proposal to include serialization? HOT 10
- Advance to stage 3 HOT 3
- Advance to stage 4 HOT 3
- performance impact with 1-million json.parse calls HOT 1
- bigint ergonomics of user-function vs options-object HOT 1
- bikeshedding the mechanism for serialization HOT 7
- Reusability of raw serialization mechanism HOT 2
- Should reviver functions still get a context argument for non-primitive values? HOT 1
- Naming of raw text placeholder
- Stage 3 Specification Review: Michael Ficarra HOT 1
- Stage 3 Specification Review: Waldemar Horwat HOT 2
- How to parse bigints when using Response.json() function? HOT 2
- Assert failed for typedValNode is an ObjectLiteral Parse Node
- Are there any implementations yet? HOT 2
- Bug in `intToBigInt`? HOT 2
- A polyfill/ponyfill implementation HOT 11
- ShallowestContainedJSONValue misrepresents negative numbers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proposal-json-parse-with-source.