Skip to content

fix: longest-prefix selection in path_of_file library mappings#1443

Merged
fblanqui merged 1 commit into
Deducteam:masterfrom
ciaran-matthew-dunne:pr/path-of-file
Jul 7, 2026
Merged

fix: longest-prefix selection in path_of_file library mappings#1443
fblanqui merged 1 commit into
Deducteam:masterfrom
ciaran-matthew-dunne:pr/path-of-file

Conversation

@ciaran-matthew-dunne

@ciaran-matthew-dunne ciaran-matthew-dunne commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

path_of_file selects the library mapping whose filesystem prefix is the longest match for the file, but when a longer match replaced a previous candidate it paired the new module path mp with the previous candidate's shorter prefix p:

| Some(_, p) ->
    if String.(length p < length fp) then mapping := Some(mp, p)  (* should be fp *)

The remainder of the file path is then computed against the wrong prefix, so with nested mappings the module path gets a duplicated directory component.

Reproduction: checking an installed Stdlib file nests two mappings ([] ↦ …/lib_root and Stdlib ↦ …/lib_root/Stdlib) automatically.

$ lambdapi check $OPAM_SWITCH_PREFIX/lib/lambdapi/lib_root/Stdlib/Set.lp
File ".../lib_root/Stdlib/Stdlib/Set.lp" (or .dk) not found.   # path_of_file = Stdlib.Stdlib.Set

Fix: store the winning mapping with its own prefix, Some(mp, fp). The command above then computes Stdlib.Set and succeeds.

@fblanqui

fblanqui commented Jul 7, 2026

Copy link
Copy Markdown
Member

Thanks!

@fblanqui fblanqui merged commit 9266beb into Deducteam:master Jul 7, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants