diff --git a/src/poetry/core/version/markers.py b/src/poetry/core/version/markers.py index 309eb3476..448a7fcba 100644 --- a/src/poetry/core/version/markers.py +++ b/src/poetry/core/version/markers.py @@ -475,6 +475,9 @@ def intersect(self, other: BaseMarker) -> BaseMarker: if other.is_empty(): return other + if isinstance(other, MarkerUnion): + return other.intersect(self) + new_markers = self._markers + [other] return MultiMarker.of(*new_markers) diff --git a/tests/version/test_markers.py b/tests/version/test_markers.py index a3b5eab43..cfe987063 100644 --- a/tests/version/test_markers.py +++ b/tests/version/test_markers.py @@ -372,6 +372,24 @@ def test_multi_marker_is_empty_is_contradictory() -> None: assert m.is_empty() +def test_multi_complex_multi_marker_is_empty() -> None: + m1 = parse_marker( + 'python_full_version >= "3.0.0" and python_full_version < "3.4.0"' + ) + m2 = parse_marker( + 'python_version >= "3.6" and python_full_version < "3.0.0" and python_version <' + ' "3.7"' + ) + m3 = parse_marker( + 'python_version >= "3.6" and python_version < "3.7" and python_full_version >=' + ' "3.5.0"' + ) + + m = m1.intersect(m2.union(m3)) + + assert m.is_empty() + + def test_multi_marker_intersect_multi() -> None: m = parse_marker('sys_platform == "darwin" and implementation_name == "cpython"')