fix: gracefully handle unknown -D options in verso-literate - #969
Open
mo271 wants to merge 1 commit into
Open
Conversation
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.
Author
|
the diff might appear larger than it really is due to whitespace, looks less scary with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
lake lintruns, it passes linter overrides to downstream executables by prefixing the options withweak.(e.g.,-Dweak.linter.style.openClassical=true).Previously,
parseDOptionstrictly relied ongetOptionDecl nameto find the expected type for an option. If the option was unknown (e.g. because of theweak.prefix or because it hasn't been registered yet),getOptionDeclthrew an internal exception, causingverso-literateto crash.This patch mirrors the behavior of
setConfigOptionin 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 theOptionsmap and defer validation to the elaborator, preventing the crash.fixes #968, see that issue for an example repo