-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: decoding dune-package crashes with (include_subdirs qualified) (#…
…10269) * test: add repro for #10264 This is only one part of the issue; the other part is more difficult to test because it is related to `Modules.t` round-tripping correctly. Signed-off-by: Etienne Millon <[email protected]> * fix: make `Module.Kind.t` round-trip correctly Signed-off-by: Etienne Millon <[email protected]> * fix: make Modules.t round-trip Fixes #10264 This part is harder to test because we can't easily load `dune-package` files in tests, nor build `Modules.t` values. Signed-off-by: Etienne Millon <[email protected]> * changelog Signed-off-by: Etienne Millon <[email protected]> --------- Signed-off-by: Etienne Millon <[email protected]>
- Loading branch information
Showing
5 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- fix crash when decoding dune-package for libraries with `(include_subdirs | ||
qualified)` (#10269, fixes #10264, @emillon) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
open Stdune | ||
module Kind = Dune_rules.Module.Kind | ||
|
||
(* See #10264 *) | ||
let%expect_test "Module.Kind encoding round trip" = | ||
let module_name s = Dune_rules.Module_name.of_string s in | ||
let test k = | ||
let ast = Kind.encode k in | ||
let sexp = Dune_sexp.Ast.add_loc ~loc:Loc.none ast in | ||
let decoded = | ||
match Dune_lang.Decoder.parse Kind.decode Univ_map.empty sexp with | ||
| r -> Ok r | ||
| exception e -> Error e | ||
in | ||
let dyn = | ||
Dyn.record | ||
[ "ast", Dyn.string (Dune_sexp.to_string ast) | ||
; "decoded", Or_exn.to_dyn Kind.to_dyn decoded | ||
] | ||
in | ||
Dune_tests_common.print_dyn dyn | ||
in | ||
test Impl; | ||
[%expect {| { ast = "impl"; decoded = Ok Impl } |}]; | ||
test (Alias []); | ||
[%expect {| { ast = "alias"; decoded = Ok Alias [] } |}]; | ||
test (Alias [ module_name "A" ]); | ||
[%expect {| { ast = "(alias (A))"; decoded = Ok Alias [ "A" ] } |}]; | ||
test (Alias [ module_name "A"; module_name "B" ]); | ||
[%expect {| { ast = "(alias (A B))"; decoded = Ok Alias [ "A"; "B" ] } |}] | ||
;; |