allow ? in identifier name

This commit is contained in:
Chris Wanstrath 2025-10-29 10:38:57 -07:00
parent 07ffc7df97
commit 40a648cd19
2 changed files with 14 additions and 1 deletions

View File

@ -36,6 +36,19 @@ describe('Identifier', () => {
FunctionCallOrIdentifier
Identifier 𝜋`)
})
test('parses identifiers with queries', () => {
expect('even? 20').toMatchTree(`
FunctionCall
Identifier even?
PositionalArg
Number 20`)
expect('even?').toMatchTree(`
FunctionCallOrIdentifier
Identifier even?`)
})
})
describe('Unicode Symbol Support', () => {

View File

@ -119,7 +119,7 @@ const consumeWordToken = (
}
// Track identifier validity: must be lowercase, digit, dash, or emoji/unicode
if (!isLowercaseLetter(ch) && !isDigit(ch) && ch !== 45 /* - */ && !isEmojiOrUnicode(ch)) {
if (!isLowercaseLetter(ch) && !isDigit(ch) && ch !== 45 /* - */ && ch !== 63 /* ? */ && !isEmojiOrUnicode(ch)) {
if (!canBeWord) break
isValidIdentifier = false
}