diff options
| -rw-r--r-- | src/type_check.ml | 3 | ||||
| -rwxr-xr-x | test/ocaml/run_tests.sh | 2 | ||||
| -rw-r--r-- | test/ocaml/vec_32_64/vec_32_64.sail | 6 | ||||
| -rw-r--r-- | test/typecheck/pass/function_namespace.sail | 11 | ||||
| -rw-r--r-- | test/typecheck/pass/function_namespace/v1.expect | 5 | ||||
| -rw-r--r-- | test/typecheck/pass/function_namespace/v1.sail | 11 |
6 files changed, 34 insertions, 4 deletions
diff --git a/src/type_check.ml b/src/type_check.ml index 2b558421..2ce7aebf 100644 --- a/src/type_check.ml +++ b/src/type_check.ml @@ -743,6 +743,9 @@ end = struct let add_local id mtyp env = begin wf_typ env (snd mtyp); + if Bindings.mem id env.top_val_specs then + typ_error (id_loc id) ("Local variable " ^ string_of_id id ^ " is already bound as a function name") + else (); typ_print ("Adding local binding " ^ string_of_id id ^ " :: " ^ string_of_mtyp mtyp); { env with locals = Bindings.add id mtyp env.locals } end diff --git a/test/ocaml/run_tests.sh b/test/ocaml/run_tests.sh index 62fe9950..40bd6af9 100755 --- a/test/ocaml/run_tests.sh +++ b/test/ocaml/run_tests.sh @@ -50,7 +50,7 @@ printf "<testsuites>\n" >> $DIR/tests.xml for i in `ls -d */`; do cd $DIR/$i; - if $SAILDIR/sail -o out -ocaml ../prelude.sail `ls *.sail` 1> /dev/null; + if $SAILDIR/sail -no_warn -o out -ocaml ../prelude.sail `ls *.sail` 1> /dev/null; then ./out > result; if diff expect result; diff --git a/test/ocaml/vec_32_64/vec_32_64.sail b/test/ocaml/vec_32_64/vec_32_64.sail index 60fa0e46..5afd421d 100644 --- a/test/ocaml/vec_32_64/vec_32_64.sail +++ b/test/ocaml/vec_32_64/vec_32_64.sail @@ -16,9 +16,9 @@ function zeros n = val main : unit -> unit function main () = { - let 'length = get_size (); - let xs = zeros(length); - if (length == 32) then { + let 'len = get_size (); + let xs = zeros(len); + if (len == 32) then { () } else { only64(xs) diff --git a/test/typecheck/pass/function_namespace.sail b/test/typecheck/pass/function_namespace.sail new file mode 100644 index 00000000..1e79f051 --- /dev/null +++ b/test/typecheck/pass/function_namespace.sail @@ -0,0 +1,11 @@ + +val test : bool -> unit + +function test _ = () + +val main: unit -> unit + +function main _ = { + let test2 = true; + test(test2) +} diff --git a/test/typecheck/pass/function_namespace/v1.expect b/test/typecheck/pass/function_namespace/v1.expect new file mode 100644 index 00000000..d01c3adb --- /dev/null +++ b/test/typecheck/pass/function_namespace/v1.expect @@ -0,0 +1,5 @@ +Type error at file "function_namespace/v1.sail", line 9, character 7 to line 9, character 10 + + let [41mtest[49m = true; + +Local variable test is already bound as a function name diff --git a/test/typecheck/pass/function_namespace/v1.sail b/test/typecheck/pass/function_namespace/v1.sail new file mode 100644 index 00000000..a72dcc11 --- /dev/null +++ b/test/typecheck/pass/function_namespace/v1.sail @@ -0,0 +1,11 @@ + +val test : bool -> unit + +function test _ = () + +val main: unit -> unit + +function main _ = { + let test = true; + test(test) +} |
