Disallow identifiers that start with a number #154
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of all, this is a breaking change. JSLT code that uses identifiers
starting with a number will fail to parse. The only redeeming feature of
this change is that this is a common restriction in many programming
languages, which should somewhat limit the risk of mayhem.
The motivation for doing this change, and one which is reflected in the
tests, is how array slicing is picky about whitespace:
.data[1:2]
would result in a cryptic error message, as the subscript was being
interpreted as an imported module's identifier:
com.schibsted.spt.data.jslt.JsltException: Parse error: Encountered " "]" "] "" at line 1, column 10.
Was expecting:
"(" ...
at :1:7
(...stacktrace follows...)
With this change, all identifiers (and references to them) are required
to start with a letter or underscore. Dashes are similarly disallowed,
to avoid conflicts with the use of a minus operator now or in the
future.