Skip to content

refactor(parser): parse None as a literal 🫥 - #229

Merged
timfennis merged 1 commit into
masterfrom
refactor/none-literal
Oct 13, 2026
Merged

timfennis merged 1 commit into
masterfrom
refactor/none-literal

Conversation

@timfennis

Copy link
Copy Markdown
Owner

None was parsed as an identifier, and the analyser and compiler each recognised it by name. So it could never be shadowed: let None = 5; print(None) printed None and silently ignored the binding. The new name resolver on feat/new-analyser would have needed a third copy of that special case. Running it over the functional tests showed 7 programs that use None disagreeing with the current pipeline, so this fixes the cause instead.

  • The lexer reads None as a keyword, and the parser produces Expression::NoneLiteral, like true and false.
  • The analyser and compiler drop their name == "None" checks and handle the literal directly.
  • The highlighter, the LSP AST walkers and LSP keyword completion know the new literal.
  • The Option page in the manual says None is a literal.

Behaviour change: binding None is now a parse error (let None = 5 reports "Invalid assignment target"), where it used to be silently ignored. A new functional test covers it. The tree-sitter grammar still treats None as an identifier, which only affects editor highlighting.

🤖 Generated with Claude Code

`None` was an identifier that the analyser and compiler each recognised
by name, so it could never be shadowed and `let None = 5` was silently
ignored. Lex it as a keyword and parse it as `Expression::NoneLiteral`,
like `true` and `false`, removing both special cases. Binding `None` is
now a parse error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T14:04:22.385657Z 92e9607 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@timfennis
timfennis merged commit 2d8e50f into master Oct 13, 2026
1 check passed
@timfennis
timfennis deleted the refactor/none-literal branch October 13, 2026 14:13
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.

1 participant