-
Notifications
You must be signed in to change notification settings - Fork 460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: accept user-defined options on the cmdline #4741
Conversation
Mathlib CI status (docs):
|
Should this also adjust |
I think it would be useful to be able to set options that are ignored if not declared in the imports. For example, suppose we want to set an option project-wide which is defined in the project itself (e.g. a mathlib linter which is supposed to only take effect in mathlib itself). In this case the file which defines the option and any files that don't import this file will have to be special cased by lake in order to avoid passing the option to these files and getting the unknown option error. This also mimics the behavior of Alternatively, this could be another type of "weak" option flag, which could be used when this is specifically the intent, and leave the default to check options eagerly. |
@digama0 We do believe that moving Mathlib's linters into a separate library (in the same repo) is achievable and independently valuable (for downstream users as well). This is likely true for other projects as well, though I don't want to exclude the possibility of adding some weak option support further down the road if the benefit is clear. |
@mhuisi We do not currently check the existence of options from |
Yes, I think you are correct. |
Even if we did move all mathlib linters into a separate |
Would it work to have a very small library |
That sounds like an okay compromise but at least it doesn't make additional support for weak options appear unreasonable. Added. |
@Kha While I very much like the notion of "weak" options here, I am worried about having two different notions of weakness between Lake and Lean. "weak" in Lake means not included in the trace. Since since options are part of the trace, that notion of weakness could applied here. Therefore, could I bike-shed for perhaps using "try" instead of "weak" as the prefix for these options? (Alternatively we could come up with another word for Lake's notion, but it seems easier to change this than that.) |
|
Or perhaps |
Collecting possible prefixes as an alternative to
Maybe in the end |
@kmill A rather verbose alternatively would be an |
src/Lean/Elab/Frontend.lean
Outdated
let name := name.replacePrefix `weak Name.anonymous | ||
let some decl := decls.find? name | ||
| unless weak do | ||
throw <| .userError s!"invalid -D parameter, unknown configuration option '{name}'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use this as an opportunity to teach about the feature?
throw <| .userError s!"invalid -D parameter, unknown configuration option '{name}'" | |
throw <| .userError s!"invalid -D parameter, unknown configuration option '{name}', if this is a user-defined option use '-D{`weak ++ name}'" |
Initial options are now re-parsed and validated after importing. Cmdline option assignments prefixed with
weak.
are silently discarded if the option name without the prefix does not exist.Fixes #3403