File tree Expand file tree Collapse file tree 8 files changed +38
-3
lines changed
Expand file tree Collapse file tree 8 files changed +38
-3
lines changed Original file line number Diff line number Diff line change 1515( package
1616 (name vult)
1717 (synopsis " Transcompiler for DSP audio" )
18- ( depends ocaml dune containers pla js_of_ocaml js_of_ocaml-ppx ounit yojson)
18+ ( depends ocaml dune containers pla js_of_ocaml js_of_ocaml-ppx ounit yojson ( ocamlformat ( = " 0.27.0 " ) ) )
1919)
2020
2121; removes the Dune__exe prefix
Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ fix16_t fix_random() {
152152 return (fix16_t )temp;
153153}
154154
155- int irandom () { return (int )rand (); }
155+ int int_random () { return (int )rand (); }
156156
157157void float_print (float value) { printf (" %f\n " , value); }
158158void fix_print (fix16_t value) { printf (" %f\n " , fix_to_float (value)); }
Original file line number Diff line number Diff line change @@ -205,7 +205,7 @@ static_inline int16_t *int16_wrap_array(const int16_t x[]) { return (int16_t *)x
205205/* Random numbers */
206206float float_random ();
207207fix16_t fix_random ();
208- int irandom ();
208+ int int_random ();
209209
210210/* Print values */
211211void float_print (float value);
Original file line number Diff line number Diff line change @@ -454,6 +454,26 @@ let checkDuplicatedVal (locals : var Map.t list) (name : string) (loc : Loc.t) :
454454 locals
455455
456456
457+ (* Helper: Check if any argument names conflict with mem variables in the context *)
458+ let checkArgumentsAgainstContext (context : context ) (args : Typed.arg list ) : unit =
459+ match context with
460+ | Some (_ , { descr = Record members ; _ } ) ->
461+ CCList. iter
462+ (fun ({ name; loc; _ } : Typed.arg ) ->
463+ match Map. find name members with
464+ | None -> ()
465+ | Some found ->
466+ Error. raiseError
467+ (" Function parameter '"
468+ ^ name
469+ ^ " ' shadows a mem variable declared at "
470+ ^ Loc. to_string_readable found.loc
471+ ^ " . Rename the parameter or the mem variable to avoid this conflict." )
472+ loc)
473+ args
474+ | _ -> ()
475+
476+
457477(* Helper: Create a reporter for mem variable updates that handles type unification *)
458478let makeMemReporter (unify : Typed.type_ -> Typed.type_ -> bool ) (t : Typed.type_ ) (found : var ) (value : var ) : var =
459479 if unify found.t t then
@@ -689,6 +709,7 @@ let enterFunction (env : env) (name : string) (args : Typed.arg list) (ret : Typ
689709 env * path * (Typed. type_ list * Typed. type_ ) =
690710 let m = getCurrentModule env in
691711 let context = getCurrentContext env in
712+ let () = checkArgumentsAgainstContext context args in
692713 let report (found : f ) =
693714 Error. raiseError (" A function with the name '" ^ found.path.id ^ " ' has already been declared." ) loc
694715 in
Original file line number Diff line number Diff line change 1+ Function parameter 'value' shadows a mem variable declared at line 2, columns 7-12. Rename the parameter or the mem variable to avoid this conflict.
2+ }
3+ and helper(value:bool) : real {
4+ ^^^^^
Original file line number Diff line number Diff line change 1+ fun process(input:real) {
2+ mem value;
3+ value = input;
4+ }
5+ and helper(value:bool) : real {
6+ if (value) return 1.0;
7+ else return 0.0;
8+ }
Original file line number Diff line number Diff line change @@ -149,6 +149,7 @@ let errors_files =
149149 ; " error43.vult"
150150 ; " error44.vult"
151151 ; " error45.vult"
152+ ; " error46.vult"
152153 ]
153154
154155
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ depends: [
1515 "js_of_ocaml-ppx"
1616 "ounit"
1717 "yojson"
18+ "ocamlformat" {= "0.27.0"}
1819 "odoc" {with-doc}
1920]
2021build: [
You can’t perform that action at this time.
0 commit comments