Skip to content
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

Undefined in nullable fields #158

Open
ivogabe opened this issue Mar 19, 2017 · 0 comments
Open

Undefined in nullable fields #158

ivogabe opened this issue Mar 19, 2017 · 0 comments

Comments

@ivogabe
Copy link

ivogabe commented Mar 19, 2017

The spec marks optional fields with | null. I was wondering whether optional fields may also be undefined. The spec describes it this way:

The loc field represents the source location information of the node. If the node contains no information about the source location, the field is null; otherwise it is an object consisting of ..

This would suggest that undefined is not allowed for these fields. Though various implementations do not set optional fields, causing that those fields are undefined. For instance, Acorn and Esprima do not set loc when location tracking is not turned on, meaning that loc is undefined. When writing transforms it is also easier to write { type: "Identifier", name: "foo" } than { type: "Identifier", loc: null, name: "foo" }.

Is the latter the desired interpretation? If so, could the spec be updated to reflect that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant