-
Notifications
You must be signed in to change notification settings - Fork 370
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
Hijack the %{?val_if_true:val_if_false}% syntax to support extending the variables of packages with + in their name #5840
Conversation
Instead of this, which is not backward compatible with opam 2.0 and 2.1, I would suggest hijacking the See the definition for the details: opam/src/format/opamTypesBase.ml Line 125 in 87a88a5
With 2.0 and 2.1 the syntax will output the empty string because the |
The workaround syntax sounds good to me! |
17ecaf7
to
f7132ff
Compare
f7132ff
to
b416532
Compare
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.
Looks good, thanks, apart from what I think is a missing colon in the to_string function? This is working for the conf-g++
adaptations I'd made (wohoo - the package is no longer called conf-mingw-w64-gplusplus-x86_64
!)
For the opam 3.0 reminder, another possibility might be to start the function in OpamFormatUpgrade
, but the TODO comment also works 🙂
The only thing that we loose is be able to express the
name1+name2+name3:var
form but this is only a syntactic sugar forname1:var & name2:var & name3:var
anyway and thename1+name2+name3:enable
syntactic sugar which we can also replace by a more explicit version if needed.
EDIT: we also can't use the ternaryvar?true:false-or-undef
inside the new clause due to the parsing rule but this is the same thing (can be desugared)
I just want to check I'm properly understanding - I think we're not losing the pkg+pkg+var
or ternary var?true:false-or-undef
here, because they don't presently work if pkg contains a +
? It's that we're "only" gaining the ability to retrieve variable values as a string?
b416532
to
1eee747
Compare
yes. What i meant was that we can't use those syntaxes inside the new one (e.g. |
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.
We also need to update the doc for that particular case.
Should we add a lint to warn that it shouldn't be acceptable to have ++
at the end of a package name (even if supported by this hack)? Users installing already present packages won't see it until they pin it, and it'll minimise new packages addition.
I don't think so. This PR basically officializes that we do accept packages with pluses in their names.
I'm not sure to understand this. |
Having a closer look, I'm afraid that the current PR is not enough to have a full support of
When a package is installed from repository, there is no display of lint warning/errors. So having a lint won't affect people installing |
I've updated the PR, details are in commit messages. Roughly there is
As usual, there is a lot of tiny commits to show/explain the diff with current PR, if accepted, i'll clean commits history in order to have it in a mergeable state. |
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.
LGTM, thanks! I also double-checked that the mingw-w64-shims (which is now in opam-repository) is still working with it.
We're missing the addition of the new syntax to the documentation (with the appropriate warnings ofc). I'll add it and rebase the branch |
b8d57b5
to
ad303d8
Compare
…le expansion, in particular when the package contains pluses
…the variables of packages with + in their name
…to fail or not when it encounters several `+` in package name (ie '"%{xx+++yy:var}%"').
… not affected by W41
…e for variable in string, and advise the good syntax.
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.
Another 2 hands PR ^^ Thanks!
^^ thanks! |
Per our own documentation, '+' should not be a valid character for packages. However packages like conf-g++ or conf-c++ now exist in the wild. This solution is a compromise in hope for {name1+name2+name3:var} to be parsable againRelated to ocaml/opam-file-format#59