Skip to content

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

Open
mo271 wants to merge 1 commit into
leanprover:mainfrom
mo271:weak_fix
Open

fix: gracefully handle unknown -D options in verso-literate#969
mo271 wants to merge 1 commit into
leanprover:mainfrom
mo271:weak_fix

Conversation

@mo271

@mo271 mo271 commented Aug 21, 2026

Copy link
Copy Markdown

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.

fixes #968, see that issue for an example repo

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
Author

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

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

1 participant