Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/tokeniser.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,15 @@ function tokenise(str) {
}
if (result === -1) {
result = attemptTokenMatch("identifier");
const token = tokens[tokens.length - 1];
if (result !== -1 && nonRegexTerminals.includes(token.value)) {
token.type = token.value;
const lastIndex = tokens.length - 1;
const token = tokens[lastIndex];
if (result !== -1) {
if (token.value === "toString") {
const message = "toString is a reserved identifier and must not be used.";
throw new WebIDLParseError(syntaxError(tokens, lastIndex, null, message));
} else if (nonRegexTerminals.includes(token.value)) {
token.type = token.value;
}
}
}
} else if (nextChar === '"') {
Expand Down
3 changes: 3 additions & 0 deletions test/invalid/baseline/tostring.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Syntax error at line 2:
DOMString toString
^ toString is a reserved identifier and must not be used.
3 changes: 3 additions & 0 deletions test/invalid/idl/tostring.webidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
interface mixin ToString {
DOMString toString();
};