Skip to content

fix: gracefully handle unknown -D options in verso-literate - #969

Merged
david-christiansen merged 4 commits into
leanprover:mainfrom
mo271:weak_fix
Sep 28, 2026
Merged

david-christiansen merged 4 commits into
leanprover:mainfrom
mo271:weak_fix

Conversation

@mo271

@mo271 mo271 commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

When lake lint runs, it passes linter overrides to downstream executables by prefixing the options with weak. (e.g., -Dweak.linter.style.openClassical=true).

Previously, parseDOption strictly relied on getOptionDecl name to find the expected type for an option. If the option was unknown (e.g. because of the weak. prefix or because it hasn't been registered yet), getOptionDecl threw an internal exception, causing verso-literate to crash.

This patch mirrors the behavior of setConfigOption in core Lean (src/Lean/Shell.lean). By using (← getOptionDecls).find? name, we can check if the option exists. If it does, we parse it according to its type. If it doesn't, we gracefully fall back to storing it as a string in the Options map and defer validation to reparseOptions, preventing the crash.

fixes #968, see that issue for an example repo.

No-Changelog: bugfix

When `lake lint` runs, it passes linter overrides to downstream executables
by prefixing the options with `weak.` (e.g., `-Dweak.linter.style.openClassical=true`).

Previously, `parseDOption` strictly relied on `getOptionDecl name` to find the
expected type for an option. If the option was unknown (e.g. because of the `weak.`
prefix or because it hasn't been registered yet), `getOptionDecl` threw an internal
exception, causing `verso-literate` to crash.

This patch mirrors the behavior of `setConfigOption` in core Lean (`src/Lean/Shell.lean`).
By using `(← getOptionDecls).find? name`, we can check if the option exists. If it does,
we parse it according to its type. If it doesn't, we gracefully fall back to storing it
as a string in the `Options` map and defer validation to the elaborator, preventing the
crash.
@mo271

mo271 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

the diff might appear larger than it really is due to whitespace, looks less scary with git diff -w

@david-christiansen

Copy link
Copy Markdown
Collaborator

Thanks for the PR, and sorry for the slow response.

From what I can see, we also need to run reparseOptions to actually remove the weak and have the option take effect with the right type. I'll update the PR branch and add a test.

Thanks again!

@david-christiansen
david-christiansen added this pull request to the merge queue Sep 28, 2026
Merged via the queue into leanprover:main with commit 499f744 Sep 28, 2026
11 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.

leanOptions handling potentially brokeen

2 participants