home
/
code
/
tiger.ml.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
WIP type-checking -- check array subscript access
[tiger.ml.git]
/
compiler
/
src
/
lib
/
tiger
/
tiger_semant.ml
diff --git
a/compiler/src/lib/tiger/tiger_semant.ml
b/compiler/src/lib/tiger/tiger_semant.ml
index
659bb85
..
3265c81
100644
(file)
--- a/
compiler/src/lib/tiger/tiger_semant.ml
+++ b/
compiler/src/lib/tiger/tiger_semant.ml
@@
-134,8
+134,13
@@
end = struct
)
)
~otherwise:(fun () -> E.raise (E.Exp_not_a_record {ty; pos}))
)
)
~otherwise:(fun () -> E.raise (E.Exp_not_a_record {ty; pos}))
- | A.SubscriptVar {var=_; exp=_; pos=_} ->
- unimplemented ()
+ | A.SubscriptVar {var; exp; pos} ->
+ let {exp=_; ty} = trvar var in
+ check_int (trexp exp) ~pos;
+ Type.if_array
+ ty
+ ~f:(fun ty_elements -> return ty_elements)
+ ~otherwise:(fun () -> E.raise (E.Exp_not_an_array {ty; pos}))
)
and trop oper ~left ~right ~pos =
let expty_left = trexp left in
)
and trop oper ~left ~right ~pos =
let expty_left = trexp left in
This page took
0.024719 seconds
and
4
git commands to generate.