Skip to content

Fix Lean character literal token scanning - #809

Merged
morluto merged 1 commit into
mainfrom
agent/fix-lean-char-literal
Aug 8, 2026
Merged

Fix Lean character literal token scanning#809
morluto merged 1 commit into
mainfrom
agent/fix-lean-char-literal

Conversation

@morluto

@morluto morluto commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Fixes #753.

The previous character-literal scanner only skipped a backslash and one following character. Valid Lean \xHH and \uHHHH literals could therefore leak hexadecimal characters into source-token inspection.

This change routes string and character literals through one delimiter-aware scanner. It skips escaped characters and scans through the matching closing delimiter, preserving the existing behavior for strings while correctly handling every current Lean character escape form.

The issue mentions \u{...}; Lean itself uses \uHHHH. The fix is grammar-agnostic within quoted literals, rather than adding a brace-escape special case.

Validation:

  • make test-component TESTS=tests/component/providers/lean/test_lean_proof_axioms.py
  • make lint-full

The repository test plan selected suite fallback because this module is transitively re-exported; the focused component regression suite directly exercises the modified behavior.

@morluto
morluto marked this pull request as ready for review August 8, 2026 04:28
@cursor

cursor Bot commented Aug 8, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@morluto
morluto merged commit bd293b2 into main Aug 8, 2026
39 checks passed
@morluto
morluto deleted the agent/fix-lean-char-literal branch August 8, 2026 04:28

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e0a441b1a7

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".



def _skip_char_literal(source: str, index: int, length: int) -> int:
return _skip_quoted_literal(source, index, length, "'")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject malformed character literals instead of scanning across lines

Because proof accepts newlines, an input such as by exact True.intro\n'\n#eval <IO action>\n' makes this helper consume everything through the final apostrophe, so _validate_source never sees the forbidden # command. Lean treats the malformed character token as an error and can recover to process later top-level commands, allowing injected evaluation or other side effects before the inspection is marked incomplete; bound character scanning to Lean's single-character escape grammar and reject a missing immediate closing delimiter rather than searching arbitrarily far ahead.

AGENTS.md reference: AGENTS.md:L16-L17

Useful? React with 👍 / 👎.

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.

[Bug]: lean_frontend _skip_char_literal mishandles multi-character escape sequences like \u{...}

1 participant