-
Notifications
You must be signed in to change notification settings - Fork 756
Description
In consume a token, the following steps are given for handling "#":
If the next input code point is a name code point or the next two input code points are a valid escape, then:
- Create a
<hash-token>.- If the next 3 input code points would start an identifier, set the
<hash-token>’s type flag to "id".- Consume a name, and set the
<hash-token>’s value to the returned string.- Return the
<hash-token>.
The "would start an identifier" check confirms that the backslash of an escape is not followed by a newline, even if the first char is hyphen, but confirming that such a backslash is not followed by EOF is deferred to "consume an escaped codepoint", via "consume a name" (step 3). Although indicated to be an error, this still yields the name that has been processed so far, and this will happen after the type flag has already been set.
I’m not sure if it really matters in practice (perhaps this is even intentional), but it struck me as odd that (assuming I’m reading it correctly) this would mean that the sequence U+0023 U+002D U+005C EOF would produce a hash token whose type is set to ID, even though "-" isn’t a valid ID.