diff --git a/src/analysis_and_optimization/Optimize.ml b/src/analysis_and_optimization/Optimize.ml index 52779e5725..f9e0e4542f 100644 --- a/src/analysis_and_optimization/Optimize.ml +++ b/src/analysis_and_optimization/Optimize.ml @@ -279,7 +279,8 @@ let rec inline_function_expression propto adt fim (Expr.Fixed.{pattern; _} as e) match suffix with | FnLpdf propto' when propto' && propto -> ( Fun_kind.FnLpdf true - , Utils.with_unnormalized_suffix fname |> Option.value_exn ) + , Utils.with_unnormalized_suffix fname + |> Option.value ~default:fname ) | FnLpdf _ -> (Fun_kind.FnLpdf false, fname) | _ -> (suffix, fname) in match Map.find fim fname' with diff --git a/src/frontend/add_missing_messages.py b/src/frontend/add_missing_messages.py index cf1c1a3bf5..11518ac86a 100755 --- a/src/frontend/add_missing_messages.py +++ b/src/frontend/add_missing_messages.py @@ -6,9 +6,9 @@ import sys parse = re.compile('File "(.*)", line (\d+).*\nError: this sentence.*\nNo sentence that leads to this state exists in "(.*)".') -parser = sys.argv[1] -new_messages = sys.argv[2] -old_messages = sys.argv[3] +parser = (Sys.get_argv ())[1] +new_messages = (Sys.get_argv ())[2] +old_messages = (Sys.get_argv ())[3] p = subprocess.run("menhir {} --compare-errors {} --compare-errors {}".format( parser, new_messages, old_messages), diff --git a/src/frontend/strip_redundant_parser_state.py b/src/frontend/strip_redundant_parser_state.py index fac60cecf1..a936a927d0 100755 --- a/src/frontend/strip_redundant_parser_state.py +++ b/src/frontend/strip_redundant_parser_state.py @@ -24,7 +24,7 @@ def strip_lines(s): if __name__ == "__main__": - with open(sys.argv[1]) as f: + with open((Sys.get_argv())[1]) as f: messages = f.read() curr = strip_redundant_parser_states(messages) while messages != curr: diff --git a/src/stan_math_backend/Stan_math_code_gen.ml b/src/stan_math_backend/Stan_math_code_gen.ml index 7e9043a53c..b0ff74a951 100644 --- a/src/stan_math_backend/Stan_math_code_gen.ml +++ b/src/stan_math_backend/Stan_math_code_gen.ml @@ -34,7 +34,8 @@ let stanc_args_to_print = && not (is_prefix ~prefix:"--filename-in-msg" x) || is_prefix ~prefix:"--o" x) in (* Ignore the "--o" arg, the stan file and the binary name (bin/stanc). *) - Array.to_list (Sys.get_argv ()) |> List.tl_exn + Array.to_list (Sys.get_argv ()) + |> List.tl_exn |> List.filter ~f:sans_model_and_hpp_paths |> String.concat ~sep:" " diff --git a/src/stanc/stanc.ml b/src/stanc/stanc.ml index 5c8f061b34..37b12bc11f 100644 --- a/src/stanc/stanc.ml +++ b/src/stanc/stanc.ml @@ -214,8 +214,9 @@ let options = let print_deprecated_arg_warning = (* is_prefix is used to also cover the --include-paths=... *) let arg_is_used arg = - Array.mem ~equal:(fun x y -> String.is_prefix ~prefix:x y) (Sys.get_argv ()) arg - in + Array.mem + ~equal:(fun x y -> String.is_prefix ~prefix:x y) + (Sys.get_argv ()) arg in if arg_is_used "--allow_undefined" then eprintf "--allow_undefined is deprecated and will be removed in Stan 2.32.0. \ diff --git a/test/integration/dune b/test/integration/dune index a53efd44bc..682d5ced41 100644 --- a/test/integration/dune +++ b/test/integration/dune @@ -1,7 +1,7 @@ (executable (name run_bin_on_args) (public_name run_bin_on_args) - (libraries core_kernel core_kernel.caml_unix)) + (libraries core_kernel core_kernel.caml_unix core_unix.sys_unix)) (cram (applies_to :whole_subtree) diff --git a/test/integration/good/code-gen/chop_summary.py b/test/integration/good/code-gen/chop_summary.py index affcbc0055..842e32639d 100644 --- a/test/integration/good/code-gen/chop_summary.py +++ b/test/integration/good/code-gen/chop_summary.py @@ -1,7 +1,7 @@ import sys import re -with open(sys.argv[1]) as f: +with open((Sys.get_argv ())[1]) as f: lines = f.readlines()[6:-6] for l in lines: cols = re.split("\s+", l)[0:7] diff --git a/test/integration/run_bin_on_args.ml b/test/integration/run_bin_on_args.ml index e1bc672740..3acfaf35ac 100644 --- a/test/integration/run_bin_on_args.ml +++ b/test/integration/run_bin_on_args.ml @@ -1,4 +1,4 @@ -open Core_kernel +open Core module Unix = Caml_unix let maybe_convert_cmd_to_windows cmd = @@ -9,7 +9,10 @@ let maybe_convert_cmd_to_windows cmd = let path = String.prefix cmd (String.substr_index_exn ~pattern cmd + String.length pattern) in - if Sys.file_exists (to_windows path) then to_windows cmd else cmd + match Sys_unix.file_exists (to_windows path) with + | `Yes -> to_windows cmd + | `No -> cmd + | `Unknown -> cmd let run_capturing_output cmd = let noflags = Array.create ~len:0 "" in @@ -21,8 +24,10 @@ let run_capturing_output cmd = String.concat ~sep:"\n" (List.concat out) let () = - let binary = Sys.argv.(1) in - let dirs = Array.(sub Sys.argv ~pos:2 ~len:(length Sys.argv - 2)) in + let binary = (Sys.get_argv ()).(1) in + let dirs = + Array.(sub (Sys.get_argv ()) ~pos:2 ~len:(length (Sys.get_argv ()) - 2)) + in Array.stable_sort ~compare:String.compare dirs ; Array.iter dirs ~f:(fun arg -> let cmd = binary ^ " " ^ arg in diff --git a/test/stancjs/run_js_on_args.ml b/test/stancjs/run_js_on_args.ml index c5b979d154..e8f474bb79 100644 --- a/test/stancjs/run_js_on_args.ml +++ b/test/stancjs/run_js_on_args.ml @@ -1,4 +1,4 @@ -open Core_kernel +open Core module Unix = Caml_unix let run_capturing_output cmd = @@ -10,7 +10,9 @@ let run_capturing_output cmd = String.concat ~sep:"\n" (List.concat out) let () = - let files = Array.(sub Sys.argv ~pos:1 ~len:(length Sys.argv - 1)) in + let files = + Array.(sub (Sys.get_argv ()) ~pos:1 ~len:(length (Sys.get_argv ()) - 1)) + in Array.stable_sort ~compare:String.compare files ; Array.iter files ~f:(fun arg -> let cmd = "node " ^ arg in diff --git a/test/unit/Ast_to_Mir_tests.ml b/test/unit/Ast_to_Mir_tests.ml index 025a5f46f7..8732a13e3e 100644 --- a/test/unit/Ast_to_Mir_tests.ml +++ b/test/unit/Ast_to_Mir_tests.ml @@ -1,6 +1,6 @@ open Frontend open Middle -open Core_kernel +open Core open Ast_to_Mir let%expect_test "Operator-assign example" = diff --git a/test/unit/Dataflow_utils.ml b/test/unit/Dataflow_utils.ml index 6a4e50d808..c9f7aa0c31 100644 --- a/test/unit/Dataflow_utils.ml +++ b/test/unit/Dataflow_utils.ml @@ -1,8 +1,8 @@ open Frontend open Middle open Analysis_and_optimization.Dataflow_utils -open Core_kernel -open Core_kernel.Poly +open Core +open Core.Poly open Analysis_and_optimization.Dataflow_types let mir_of_string s = diff --git a/test/unit/Debug_data_generation_tests.ml b/test/unit/Debug_data_generation_tests.ml index f033ca7d67..f577c48ffe 100644 --- a/test/unit/Debug_data_generation_tests.ml +++ b/test/unit/Debug_data_generation_tests.ml @@ -1,5 +1,5 @@ open Analysis_and_optimization -open Core_kernel +open Core open Frontend open Debug_data_generation diff --git a/test/unit/Dependence_analysis.ml b/test/unit/Dependence_analysis.ml index e2d6b3b131..fc475f71c3 100644 --- a/test/unit/Dependence_analysis.ml +++ b/test/unit/Dependence_analysis.ml @@ -1,4 +1,4 @@ -open Core_kernel +open Core open Frontend open Analysis_and_optimization.Dependence_analysis open Middle diff --git a/test/unit/Desugar_test.ml b/test/unit/Desugar_test.ml index b17e52a58f..6004819418 100644 --- a/test/unit/Desugar_test.ml +++ b/test/unit/Desugar_test.ml @@ -1,4 +1,4 @@ -open Core_kernel +open Core open Analysis_and_optimization let to_mir s = diff --git a/test/unit/Factor_graph.ml b/test/unit/Factor_graph.ml index 024ae3bae1..e5b7833a95 100644 --- a/test/unit/Factor_graph.ml +++ b/test/unit/Factor_graph.ml @@ -1,6 +1,6 @@ open Frontend open Analysis_and_optimization.Factor_graph -open Core_kernel +open Core open Analysis_and_optimization.Dataflow_types let reject_example = diff --git a/test/unit/Optimize.ml b/test/unit/Optimize.ml index 6a2b263751..b7ff5cc14a 100644 --- a/test/unit/Optimize.ml +++ b/test/unit/Optimize.ml @@ -1,4 +1,4 @@ -open Core_kernel +open Core open Frontend open Analysis_and_optimization.Optimize open Middle diff --git a/test/unit/Parse_tests.ml b/test/unit/Parse_tests.ml index 86bccfea68..401c0b9721 100644 --- a/test/unit/Parse_tests.ml +++ b/test/unit/Parse_tests.ml @@ -1,4 +1,4 @@ -open Core_kernel +open Core open Frontend let print_ast_of_string s = diff --git a/test/unit/Semantic_check_tests.ml b/test/unit/Semantic_check_tests.ml index 25ec49ec80..93435e06d2 100644 --- a/test/unit/Semantic_check_tests.ml +++ b/test/unit/Semantic_check_tests.ml @@ -1,4 +1,4 @@ -open Core_kernel +open Core open Frontend open Frontend_utils