Skip to content

Editorial: pass necessary arguments to SerializeJSON*#1890

Merged
ljharb merged 1 commit intomasterfrom
json-state
Mar 13, 2020
Merged

Editorial: pass necessary arguments to SerializeJSON*#1890
ljharb merged 1 commit intomasterfrom
json-state

Conversation

@bakkot
Copy link
Copy Markdown
Member

@bakkot bakkot commented Mar 6, 2020

SerializeJSONProperty , SerializeJSONObject, and SerializeJSONArray refer to variables which they have not been passed using notation like SerializeJSONProperty has access to _ReplacerFunction_ from the invocation of the `stringify` method.

I find this sketchy (see #1884).

This PR makes all the necessary values be passed explicitly, wrapped up in a Record.

@ljharb ljharb requested review from a team, ljharb, michaelficarra and syg March 6, 2020 18:13
Copy link
Copy Markdown
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestions optional

Comment thread spec.html
Comment thread spec.html
Comment thread spec.html
@ljharb ljharb self-assigned this Mar 6, 2020
@bakkot
Copy link
Copy Markdown
Member Author

bakkot commented Mar 6, 2020

Hm. Asserting that something is a Record isn't all that useful, since that tells you nothing about the fields in that record, which are just as important. So I think I'd prefer to omit those assertions, though it's not a strong preference.

@ljharb
Copy link
Copy Markdown
Member

ljharb commented Mar 6, 2020

In general I prefer abstract ops to assert about their arguments as strongly as possible; certainly we could make a JSONStateRecord type and assert it's one of those (which would include the slots), but that feels a bit overkill here.

@bakkot
Copy link
Copy Markdown
Member Author

bakkot commented Mar 6, 2020

I agree that it feels like overkill to make such an assertion, but at that point I don't really see the value of making any assertion at all. There's nowhere else in the spec we just assert something is a Record, as far as I know.

Copy link
Copy Markdown
Contributor

@syg syg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup, lgtm.

Comment thread spec.html
@ljharb ljharb merged commit 2b8561c into master Mar 13, 2020
@ljharb ljharb deleted the json-state branch March 13, 2020 21:14
ljharb pushed a commit to jmdyck/ecma262 that referenced this pull request Mar 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants