Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Incorrect "keyword" value for the key of object property which looks like an boolean #18

Closed
markelog opened this issue Apr 6, 2016 · 6 comments

Comments

@markelog
Copy link

markelog commented Apr 6, 2016

For the case like

({true: 1})

token for the key, will look like this -

{
  "type": {
    "label": "true",
    "keyword": "true",
    "beforeExpr": false,
    "startsExpr": true,
    "rightAssociative": false,
    "isLoop": false,
    "isAssign": false,
    "prefix": false,
    "postfix": false,
    "binop": null,
    "updateContext": null
  },
  "value": "true"
}

I believe "keyword": "true" bit should look like this - "keyword": undefined or "keyword": false

@hzoo
Copy link
Member

hzoo commented Apr 6, 2016

This is probably true for other keywords as object keys like say function then right?

@markelog
Copy link
Author

markelog commented Apr 6, 2016

yeah

@loganfsmyth
Copy link
Member

It is a keyword though, right? It's just that in this instance, a keyword is allowed as a name, it doesn't make the token less of a keyword token.

@mdevils
Copy link

mdevils commented Apr 6, 2016

Keyword token plays role of a keyword. In this case it's just an identifier.

@markelog
Copy link
Author

markelog commented Apr 7, 2016

I'd say it is a matter of interpretation - like in ast it is definitely an identifier, whereas in tokens list it is could be interpreted as keyword (and might be useful in some situations), although, tokens are needed to do an ast and it is pretty hard to distinguish it from other entities, since those and this token are identical, so we would need to analyze the surroundings and stuff. On the other hand other tokenizers consider this a keyword.

I think everybody would win if we would add a clarifier - another flag, property. As a bonus no one would consider this a breaking change, if that sounds acceptable we can provide a pr btw.

Also, on the side note - i think for the case like

({ "something": 1 })

keyword property for something token shouldn't be an undefined but false?

@babel-bot
Copy link

This issue has been moved to babel/babel#6724.

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

No branches or pull requests

6 participants