Skip to content

Fix comment stripping crash on /- inside string literals#20

Merged
chanind merged 1 commit into
mainfrom
fix/string-literal-comment-parsing
Mar 31, 2026
Merged

Fix comment stripping crash on /- inside string literals#20
chanind merged 1 commit into
mainfrom
fix/string-literal-comment-parsing

Conversation

@chanind

@chanind chanind commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • The daily crawl has been failing since March 27 because scripts/find_command_range.lean was added to mathlib4 containing /- inside a string literal (e.g. s.startsWith "/-")
  • The comment stripper was treating this as a block comment start, then crashing with LeanParseError: Cannot find closing comment delimiter
  • Added _find_outside_strings() helper that skips string literals when searching for /- and -- delimiters at the top level. Inside block comments, strings are not special per Lean's grammar, so existing behavior is preserved.

Test plan

  • All 18 existing tests pass
  • Added 2 new tests for /- inside string literals (alone and mixed with real comments)
  • mypy, flake8, black all pass
  • Verified fix works against content matching the failing find_command_range.lean

🤖 Generated with Claude Code

The crawler has been failing since March 27 because mathlib4 added
scripts/find_command_range.lean which contains /- inside a string
literal (e.g. `s.startsWith "/-"`). The comment stripper was treating
this as a block comment start, then failing to find the closing -/.

Add _find_outside_strings() helper that skips string literals when
searching for comment delimiters at the top level. Inside block
comments, strings are not special per Lean's grammar, so the existing
behavior is preserved there.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@chanind chanind merged commit 134f72f into main Mar 31, 2026
3 checks passed
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