Comments (21)
@Seldaek I am still uncertain about how this should be parsed (e.g. is it a matter of order or operator precedence?). It seems like a bug to me, but want to check with you first.
Outcome of the above constraint is:
class Composer\Semver\Constraint\MultiConstraint#10 (3) {
protected $constraints =>
array(2) {
[0] =>
class Composer\Semver\Constraint\Constraint#11 (3) {
protected $operator =>
int(4)
protected $version =>
string(12) "0.13.0.0-dev"
protected $prettyString =>
NULL
}
[1] =>
class Composer\Semver\Constraint\Constraint#12 (3) {
protected $operator =>
int(1)
protected $version =>
string(22) "2.0.0.0-dev != 1.3.1.0"
protected $prettyString =>
NULL
}
}
protected $prettyString =>
string(18) "~0.13|~1.0 !=1.3.1"
protected $conjunctive =>
bool(true)
}
from semver.
it's parsed like that because it's collapsed
https://github.com/composer/semver/blob/master/src/VersionParser.php#L263-L277
That constraint still looks ok though? so maybe a solver bug?
from semver.
the issue here is that the upper bound is parsed as being 2.0.0.0-dev != 1.3.1.0
, instead of using 2 different constraints here.
Can you try to add a comma between ~1.0
and != 1.3.1
?
from semver.
doesn't help unfortunately stof.
from semver.
Looks like the regex splitting the AND constraints does not play well with the !=
operator
from semver.
looks ok to me...
Composer\Semver\Constraint\MultiConstraint::__set_state(array(
'constraints' =>
array (
0 =>
Composer\Semver\Constraint\Constraint::__set_state(array(
'operator' => 4,
'version' => '1.0.0.0-dev',
'prettyString' => NULL,
)),
1 =>
Composer\Semver\Constraint\Constraint::__set_state(array(
'operator' => 1,
'version' => '2.0.0.0-dev',
'prettyString' => NULL,
)),
2 =>
Composer\Semver\Constraint\Constraint::__set_state(array(
'operator' => 5,
'version' => '1.3.1.0',
'prettyString' => NULL,
)),
),
'prettyString' => NULL,
'conjunctive' => true,
))
[>= 1.0.0.0-dev < 2.0.0.0-dev != 1.3.1.0]
from semver.
well, in this case, yes. But try with ~1.0 !=1.3.1
, which is what was reported here
from semver.
that is for ~1.0 !=1.3.1,
from semver.
I suspect it has to do with attempting to collapse the contiguous range (since ~0.x || ~1.x
is a contiguous range) not properly taking into account the exclude.
from semver.
that's what i said 😉
from semver.
I am confused. I wrote some tests, but they all work as expected..
from semver.
Never mind. Added some more assertions. The string representation is identical. The actual count of constraints inside the multiconstraint is not.
from semver.
Here is a simple debugging session against the given constraint in the crucial part of the code.
from semver.
Due to the simple string comparison in there things do not end up as expected. Not sure what the most elegant solution would be here?
from semver.
I don't think it's an issue here tbh, the parsing looks fine, and it should work.. collapsing that range isn't wrong AFAICT, as >=0.13 AND <2.0 AND not 1.3.1
should result in the correct stuff being picked. I am wondering if it's not instead something going of in the solver or the evaluation of the constraint.. But it's kinda late here so maybe I'm missing something :)
from semver.
The problem is that the upper bound + the exclude are merged into one constraint, while they should be a multiconstraint (or separate constraints in the multiconstraint being generated). You cannot have a single constraint that represents both the upper bound and the exclusion because a constraint only has one operator.
from semver.
Now it actually translates into (>="0.13") AND (<"2.0 AND NOT 1.3.1")
(quotes and brackets added for clarity). So it simply acts as an upper bound only, the "NOT" gets lost in conversion through collapsing.
from semver.
In #42 (comment) the operator => 5
contains the NOT, so I think that's fine.
from semver.
feel free to reopen the original composer/composer#5617 if you think it's a solver issue.
from semver.
@Seldaek that is proper parsing yes. But that only happens when there is not a contiguous range (the constraint used there was ~1.0 !=1.3.1
, not ~0.13 || ~1.0 !=1.3.1
).
from semver.
As you can see in my debug session, it initially creates two multi constraints, the first containing lower and upper bound, and the second containing lower and upper bound and the not constraint. When it merges them it ends up with only a lower and upper bound. See #42 (comment) for details.
from semver.
Related Issues (20)
- VersionParser accepts and further corrupts badly formatted version string HOT 5
- VersionParser crashed on version constraint like "dev-load-varnish-only-when-used as ^2.0@dev" HOT 1
- Sanitize version constraints HOT 1
- Could not parse version constraint @dev: Invalid version string "@dev" HOT 9
- UnexpectedValueException when running composer update HOT 1
- Proposal: Move functions out of Intervals class HOT 1
- Invalid version string "CLX6_2020R01-dev" in "dev-code-refactory-for-better-readability as CLX6_2020R01-dev", the alias must be an exact version HOT 3
- dev-trunk vs. dev-master HOT 2
- Previously invalid versions now valid (Bad aliases this time) HOT 4
- Invalid version string "8.x-1.x-dev" #671 HOT 2
- Invalid version string for some default PHP version naming scheme HOT 3
- Incorrect result of \Composer\Semver\Constraint\ConstraintInterface::matches() HOT 2
- PHP 8.1 compatibility - Passing null to parameter #1 ($string) of type string is deprecated - VersionParser.php:105 HOT 8
- VersionParser->normalize() returns invalid versions HOT 3
- versionRegex in VersionParser->parseConstraint has a dead match HOT 1
- Bumping patch version by one HOT 2
- Support larger MAJOR version numbers
- Unsatisfiable constraint must throw instead of compacting to empty HOT 6
- Inconsistent application of stability flags in parseConstraint HOT 6
- aren't 1.0 and 1.0.0 equal? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from semver.