Allow Path.is_descendant to work on external paths.#14382
Open
ElectreAAS wants to merge 1 commit intoocaml:mainfrom
Open
Allow Path.is_descendant to work on external paths.#14382ElectreAAS wants to merge 1 commit intoocaml:mainfrom
Path.is_descendant to work on external paths.#14382ElectreAAS wants to merge 1 commit intoocaml:mainfrom
Conversation
Collaborator
Leonidas-from-XIV
left a comment
There was a problem hiding this comment.
Looks like a solid improvement. I have one question that would be good to have an answer to, besides that it gets a solid 👍 from me.
There was a problem hiding this comment.
Pull request overview
This PR updates Stdune.Path.is_descendant so that it correctly handles External paths (instead of always returning false), aligning behavior with the other Path.t variants and updating tests accordingly.
Changes:
- Delegate
Path.is_descendanttoPath.External.is_descendantwhen both arguments areExternal. - Adjust
Path.External.is_descendantto consider equality (a = b) as a descendant relationship. - Update
stduneexpect tests to assert the newExternaldescendant behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| otherlibs/stdune/src/path.ml | Adds an External/External case to Path.is_descendant. |
| otherlibs/stdune/src/path_external.ml | Updates external descendant logic to include equality and prefix-based checks. |
| otherlibs/stdune/test/path_tests.ml | Updates expectations to reflect the new External descendant semantics. |
Signed-off-by: Ambre Austen Suhamy <ambre@tarides.com>
56ed740 to
887de1d
Compare
Leonidas-from-XIV
approved these changes
Apr 30, 2026
6 tasks
Alizter
requested changes
Apr 30, 2026
Collaborator
Alizter
left a comment
There was a problem hiding this comment.
There are a lot of consumers of this function so I would like to conduct a thorough review. This will take time to do so I will block this PR in the meantime so there are no misunderstandings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracted from #13792.
Right now,
Path.is_descendantcan be called on twoPath.t, whatever their subtype, but if at least one of them is anExternal, it will always returnfalse.This is surprising, you'd expect
is_descendant (e "/foo/bar") ~of_:(e "/");to returntrue, to quote one test.This PR extends
Path.is_descendantto use the already existingPath.External.is_descendant, mirroring other type variants.To further mirror other variants,
Path.External.is_descendantis patched to include... || a = b.