From fd7b60edc21ac40ad346ff4194ccfdc0920358d4 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Wed, 22 Feb 2023 19:16:09 -0800 Subject: [PATCH 1/2] melange: use the correct order for `include_dirs` load path --- jscomp/main/melc.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jscomp/main/melc.ml b/jscomp/main/melc.ml index c7f216d025..21b9570648 100644 --- a/jscomp/main/melc.ml +++ b/jscomp/main/melc.ml @@ -234,7 +234,10 @@ let main: Melc_cli.t -> _ Cmdliner.Term.ret } -> if help then `Help (`Auto, None) else begin try - Clflags.include_dirs := include_dirs @ !Clflags.include_dirs; + Clflags.include_dirs := + (* The OCaml compiler expects include_dirs in reverse CLI order, but + cmdliner returns it in CLI order. *) + List.rev_append include_dirs !Clflags.include_dirs; Ext_list.iter alerts Warnings.parse_alert_option; Ext_list.iter warnings (fun w -> Option.iter From 131c2daf20bf06ae4390e605d7a0efe40711b2c1 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Wed, 22 Feb 2023 21:25:55 -0800 Subject: [PATCH 2/2] Use `List.rev_append` in `Res_compmisc.init_path` add changelog entry --- Changes.md | 2 ++ jscomp/core/res_compmisc.ml | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Changes.md b/Changes.md index 824f41e28f..4f9314ccf4 100644 --- a/Changes.md +++ b/Changes.md @@ -29,6 +29,8 @@ Unreleased ([#482](https://github.com/melange-re/melange/pull/482)) - melange: fix codegen issue accessing a nested module path that is also `include`d ([#487](https://github.com/melange-re/melange/pull/487)) +- melange: preserve the correct command-line order for load path directories + ([#492](https://github.com/melange-re/melange/pull/492)) 0.3.2 2022-11-19 --------------- diff --git a/jscomp/core/res_compmisc.ml b/jscomp/core/res_compmisc.ml index 54eafbb669..facf1d5714 100644 --- a/jscomp/core/res_compmisc.ml +++ b/jscomp/core/res_compmisc.ml @@ -28,8 +28,10 @@ let init_path () = List.map (Misc.expand_directory Config.standard_library) dirs in Load_path.reset (); - List.iter Load_path.add_dir - (List.rev (Lazy.force Js_config.stdlib_path :: exp_dirs)); + let exp_dirs = + List.rev_append exp_dirs [ Lazy.force Js_config.stdlib_path ] + in + List.iter Load_path.add_dir exp_dirs; Ext_log.dwarn ~__POS__ "Compiler include dirs: %s@." (String.concat "; " (Load_path.get_paths ()));