-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
_symbol_ is an |Identifier| ? #831
Comments
|
Sorry, I don't understand what you're saying. In particular, could you explain what you mean by It might help to say that I'm not concerned about the |
I'm looking at the Contains algorithm, and the first and third sections recursively call into the Contains algorithm with a MemberExpression and a CallExpression, respectively. However, since both sections return early if symbol is a reserved word, and since Identifier is "an IdentifierName that's not a reserved word", after step 2, "symbol" can't possibly be an Identifier but not an IdentifierName - so at the least, "Identifier" should be changed to "IdentifierName", by my reading? Beyond that, I'm not sure about why step 3 is there. @allenwb @bterlson, any idea? |
if the spec text said: If someMemberExpression Contains the Identifier foo ... and someMemberExpression is a parse node for: then Contains needs to return true. But if the call to Contains was If someMemberExpression Contains super ... and someMemberExpression is a parse node for: it needs to return false because in this context super is not being used as a keyword, it is just an ordinary IdentifierName The first case is not currently used in spec. The second case definitely is. The reason that case is in the spec, even though it is never used, is that all definitions or Contain try to be complete about defining what it means for terminal or non-terminal grammar symbol to be used in a specific kind of parse node. |
@allenwb since Regarding completeness, that makes sense. |
Yes, step 3 is for the other case. An the StringValue call is needed to make sure that IdentiferNames contain unicode escapes get normalized before the comparison. |
Got it, thanks! @jmdyck, this seems answered, so I'll close it - happy to reopen if not. |
Ah, okay, that explains a lot. The problem with that hypothetical usage is, the definition of Contains says that
To me, it's like an operation that says parameter One way to resolve the inconsistency would be to delete the occurrences of step 3. Since the spec has none of the invocations of Contains for which that step is intended, there should be no effect. Another way to resolve the inconsistency would be to re-word the definition(s) of Contains so that |
I don't think that would be a good idea as Contains is recursive and some point somebody might define a rule that does Contains using some identifier name and there is a good chance they wouldn't know that they need to update some definitions of Contains to make it work. IdentifierName is a lexical production that is used as a terminal symbol of the syntactic grammar and StringValue is explicitly defined for it. I think the meaning of StringValue of "IdentiferName foo" has a pretty clear meaning. If they said "Identifier foo" then it is pretty clear that they mean an Identifier that contains an IdentifierName whose StringValue is "foo". You can try to tweak the language, but it remains to be seen in the end it will be clearer to a human reader. |
Well, I'm not sure that the application of StringValue goes without saying, but that's beside the point -- even if someone wrote |
Yeah, I'll submit a PR. |
... specifically, steps of the form: If _symbol_ is an |Identifier| and StringValue of _symbol_ is the same value as the StringValue of |IdentifierName|, return *true*. Resolves issue tc39#831. As @allenwb points out, the intended use case for such steps does not occur in the spec. And as I point out, these steps are semantically problematic. If the intended use case ever *does* occur, I'm guessing we'll find a different way to handle it.
... specifically, steps of the form: If _symbol_ is an |Identifier| and StringValue of _symbol_ is the same value as the StringValue of |IdentifierName|, return *true*. Resolves issue tc39#831. As @allenwb points out, the intended use case for such steps does not occur in the spec. And as I point out, these steps are semantically problematic. If the intended use case ever *does* occur, I'm guessing we'll find a different way to handle it.
In four of the definitions for 'Contains', there's the step:
I'm struggling to understand what this means. To me, it appears to make a category error (twice), treating
_symbol_
(which is a grammar symbol) as if it's a Parse Node.Consider just the phrase
_symbol_ is an |Identifier|
. Can someone suggest an example in which that phrase is found to be true? I.e., where some actual rule (e.g. an early error rule) causes (eventually) an invocation of one of those four definitions of Contains, and control reaches that step, and_symbol_ is an |Identifier|
is true, according to some interpretation?The text was updated successfully, but these errors were encountered: