Parser: fix ambiguity with whitespace in version ranges#40344
Parser: fix ambiguity with whitespace in version ranges#40344haampie merged 8 commits intospack:developfrom
Conversation
Allowing white space introduces an ambiguity: ``` spack spec a@1: b ``` parses as `a@1:b` but should be parsed as two separate specs `a@1:` and `b`
848aeb9 to
fb43645
Compare
This reverts commit 96f4e98.
d0529a2 to
55ab8ca
Compare
Which package relies on this? |
|
spack/var/spack/repos/builtin/packages/py-wasabi/package.py Lines 19 to 23 in e2a7f2e |
alalazo
left a comment
There was a problem hiding this comment.
LGTM, but let's wait for at least another ✔️ for the breaking change.
becker33
left a comment
There was a problem hiding this comment.
Can you add this detail to the comment at the top of lib/spack/spack/parser.py? I think that's the only relevant documentation to update.
There was a problem hiding this comment.
Since this is breaking anyway I don't think it's unreasonable to not support the py-wasabi case. We generally require a space to differentiate key-value pairs in other places... I don't see why we shouldn't also require it after a version range.
so, disallow:
a@1:b = c
and require this space:
a@1: b = c
^
Or do folks object?
|
These are all valid:
Maybe All whitespace in verison specifiers should've been banned from the start ;p |
|
I don’t think it’s inconsistent. In other places we change context based on sigils, and require space for kvp’s (which start with an identifier). This is just (I think?) the only place where there is a word boundary because of a colon at the end of the thing before a kvp. OTOH, if there is no need to disable support for it (does it introduce ambiguity or just weirdness?) then it could stay like it is. |
|
It's not ambiguous, |
What do you want to add exactly? Those high-level rules are generally unclear about use of white space, as I read them they're even more strict than what we allow, but it's hard to follow since it's not valid EBNF. I think the implementation + tests are the only correct documentation |
|
Ping @becker33 |
1 similar comment
|
Ping @becker33 |
Allowing white space around `:` in version ranges introduces an ambiguity: ``` a@1: b ``` parses as `a@1:b` but should really be parsed as two separate specs `a@1:` and `b`. With white space disallowed around `:` in ranges, the ambiguity is resolved.
Allowing white space around `:` in version ranges introduces an ambiguity: ``` a@1: b ``` parses as `a@1:b` but should really be parsed as two separate specs `a@1:` and `b`. With white space disallowed around `:` in ranges, the ambiguity is resolved.
Fixes #40342
This is a breaking change, but imho
developis broken, so it's rather a bugfix.Allowing white space around
:in version ranges introduces an ambiguity:parses as
a@1:bbut should really be parsed as two separate specsa@1:andb.With white space disallowed around
:in ranges, the ambiguity is resolved.White space is still allowed around the
,separator in version lists, since there we unambiguously require a next version/range token anyways, and in fact the syntax with whitespaces around,is used in a bunch of packages.Apart from that, there's this rather odd, supported syntax:
It's parsed as
[a, @1:, b=c]. Apparently this syntax is relied on in exactly one package -- I think disallowing that would have made sense if it wasn't relied on... I've left this as is, and added an additional test for this syntax.