summaryrefslogtreecommitdiff
path: root/test/typecheck
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-11-12 20:39:17 +0000
committerAlasdair Armstrong2018-11-12 20:39:17 +0000
commit76d5e3227d529f6ef23a822e498b476e9bccae5c (patch)
tree934dc9c304ea4c656c22c73ac903563eaf0deee3 /test/typecheck
parente5b80f77cb481938f6ddaab629e017083723a5c6 (diff)
Make type checker smarter at inferring l-expressions
Previously the following would fail: ``` default Order dec $include <prelude.sail> register V : vector(1, dec, vector(32, dec, bit)) val zeros : forall 'n, 'n >= 0. unit -> vector('n, dec, bit) function main() : unit -> unit = { V[0] = zeros() } ``` Since the type-checker wouldn't see that zeros() must have type `vector(32, dec, bit)` from the type of `V[0]`. It now tries both to infer the expression, and use that to check the assignment, and if that fails we infer the lexp to check the assignment. This pattern occurs a lot in ASL, and we often had to patch zeros() to zeros(32) or similar there.
Diffstat (limited to 'test/typecheck')
-rw-r--r--test/typecheck/pass/lexp_vec.sail11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/typecheck/pass/lexp_vec.sail b/test/typecheck/pass/lexp_vec.sail
new file mode 100644
index 00000000..605c3855
--- /dev/null
+++ b/test/typecheck/pass/lexp_vec.sail
@@ -0,0 +1,11 @@
+default Order dec
+
+$include <prelude.sail>
+
+register V : vector(1, dec, vector(32, dec, bit))
+
+val zeros : forall 'n, 'n >= 0. unit -> vector('n, dec, bit)
+
+function main() : unit -> unit = {
+ V[0] = zeros()
+}