Skip to content

Commit

Permalink
update to new opam stuff and fix deprecated function inlining
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveBronder committed Apr 8, 2022
1 parent aa1fe0c commit d47a1bf
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 26 deletions.
3 changes: 2 additions & 1 deletion src/analysis_and_optimization/Optimize.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/add_missing_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/strip_redundant_parser_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion src/stan_math_backend/Stan_math_code_gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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:" "

Expand Down
5 changes: 3 additions & 2 deletions src/stanc/stanc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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. \
Expand Down
2 changes: 1 addition & 1 deletion test/integration/dune
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/good/code-gen/chop_summary.py
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
13 changes: 9 additions & 4 deletions test/integration/run_bin_on_args.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Core_kernel
open Core
module Unix = Caml_unix

let maybe_convert_cmd_to_windows cmd =
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions test/stancjs/run_js_on_args.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Core_kernel
open Core
module Unix = Caml_unix

let run_capturing_output cmd =
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/unit/Ast_to_Mir_tests.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
open Frontend
open Middle
open Core_kernel
open Core
open Ast_to_Mir

let%expect_test "Operator-assign example" =
Expand Down
4 changes: 2 additions & 2 deletions test/unit/Dataflow_utils.ml
Original file line number Diff line number Diff line change
@@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion test/unit/Debug_data_generation_tests.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open Analysis_and_optimization
open Core_kernel
open Core
open Frontend
open Debug_data_generation

Expand Down
2 changes: 1 addition & 1 deletion test/unit/Dependence_analysis.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Core_kernel
open Core
open Frontend
open Analysis_and_optimization.Dependence_analysis
open Middle
Expand Down
2 changes: 1 addition & 1 deletion test/unit/Desugar_test.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Core_kernel
open Core
open Analysis_and_optimization

let to_mir s =
Expand Down
2 changes: 1 addition & 1 deletion test/unit/Factor_graph.ml
Original file line number Diff line number Diff line change
@@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion test/unit/Optimize.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Core_kernel
open Core
open Frontend
open Analysis_and_optimization.Optimize
open Middle
Expand Down
2 changes: 1 addition & 1 deletion test/unit/Parse_tests.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Core_kernel
open Core
open Frontend

let print_ast_of_string s =
Expand Down
2 changes: 1 addition & 1 deletion test/unit/Semantic_check_tests.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Core_kernel
open Core
open Frontend
open Frontend_utils

Expand Down

0 comments on commit d47a1bf

Please sign in to comment.