X-Git-Url: https://git.xandkar.net/?p=tiger.ml.git;a=blobdiff_plain;f=compiler%2Fsrc%2Flib%2Ftiger%2Ftiger_semant.ml;h=3265c81cbd887777550c6d23ad105e4b22d74215;hp=659bb8542d1469c99150cfda352f73cfdf3a01da;hb=161a300dddce2df54b21863ae94e2dda281906fd;hpb=523e2b063b9ba20329af61e18dc9a5ccbaca06a0 diff --git a/compiler/src/lib/tiger/tiger_semant.ml b/compiler/src/lib/tiger/tiger_semant.ml index 659bb85..3265c81 100644 --- 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})) - | 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