Skip to content

Allow reserved identifiers as operation argument names - #849

Open
dingjethw wants to merge 2 commits into
w3c:mainfrom
dingjethw:fix-785
Open

dingjethw wants to merge 2 commits into
w3c:mainfrom
dingjethw:fix-785

Conversation

@dingjethw

Copy link
Copy Markdown

Per https://webidl.spec.whatwg.org/#idl-names, the reserved identifier rule (constructor, toString, leading _) exempts operation arguments, but the check ran inside tokenise() — before the parser could know the syntactic position — so undefined foo(unsigned long toString); was wrongly rejected.

The check now runs after parsing in parseByTokens(): argument name tokens are exempt, every other use still throws the same parse-time error. Regenerated invalid baselines only gained the source name and full source line in the error context (same caret, same message).

Covered by a new syntax test (argument-reserved-name.webidl: toString, _toString, _constructor as argument names in an interface operation and a callback); existing invalid tests for operation/typedef names still pass. npm test (eslint + tsc + webpack + mocha): 297 passing.

Fixes #785

Per https://webidl.spec.whatwg.org/#idl-names, the reserved identifier
rule exempts operation arguments, but the tokeniser rejected reserved
names before the parser could know the syntactic position.

The check now runs after parsing: reserved tokens used as argument
names are exempt, every other use still throws the same parse error.

Fixes w3c#785
Attribute, constant, enum, dictionary field, namespace and typedef
names must still reject reserved identifiers.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

'toString' is supposed to be a valid operation argument name

2 participants