fix: identifier regexp supports unicode identifiers - #2393
fix: identifier regexp supports unicode identifiers#2393Ilya Trapashko (itrapashko) wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/adapter/variableStore.ts:91
privatePropertyReis too permissive: it allows an empty private identifier ("#") and allows starting withID_Continuecharacters (e.g. digits), which are not valid as the first character of aPrivateIdentifier. This can produce invalidthis.#...evaluateNames.
const privatePropertyRe = /^#[$_\u200C\u200D\p{ID_Continue}]*$/u;
src/adapter/completions.ts:285
- Comment has a grammar typo: "properties are aren't" should be "properties that aren't".
// For any properties are aren't valid identifiers, quote them as foo['bar!']
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/adapter/completions.ts:288
- The updated identifier validation now treats Unicode identifier characters as valid. Since there’s existing coverage for completion quoting behavior (see src/test/completion/completion.test.ts), consider adding a test case that verifies a non-ASCII but valid identifier (e.g.
obj.π|orobj.привет|) is not converted to bracket access, while an invalid name (space/punctuation) still is. This helps prevent regressions in the new Unicode behavior.
// For any properties that aren't valid identifiers, quote them as foo['bar!']
for (const item of result) {
if (!validIdentifierRe.test(item.label)) {
item.text = `[${JSON.stringify(item.label)}]`;
|
Connor Peet (@connor4312) I have added test to |
Connor Peet (connor4312)
left a comment
There was a problem hiding this comment.
THis is good, thanks!
Fixes #2391
The new regular expression supports all JavaScript identifiers. It was taken from the following article: https://v8.dev/features/regexp-match-indices