diff options
| author | Alasdair Armstrong | 2018-02-01 16:31:36 +0000 |
|---|---|---|
| committer | Alasdair Armstrong | 2018-02-01 16:31:36 +0000 |
| commit | 49dde317c5f211c47c84f84658d6bf96e4b98f9f (patch) | |
| tree | 4e3fac053bc551fcdddcaf53579a30adb36a2c20 /test | |
| parent | e9311f6ba7a59db19417902403880753530cb788 (diff) | |
Fix a bug where local variables could shadow functions
Currently the fix is to disallow this shadowing entirely, because it
seems to cause trouble for ocaml.
Diffstat (limited to 'test')
| -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 |
5 files changed, 31 insertions, 4 deletions
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) +} |
