X-Git-Url: https://git.xandkar.net/?p=tiger.ml.git;a=blobdiff_plain;f=compiler%2Fsrc%2Flib%2Ftiger%2Ftiger_semant.ml;h=5d5d71b2c026f567669ef47c409a86453614cbab;hp=ca4b489f825d94e16f92725d85e1cf9ebc4bfcb5;hb=4c550cd5b9653add413e21d06c73efe3aa657e06;hpb=0ed7a07cf496065c3ff0d0f9325ae8c516b00c1b diff --git a/compiler/src/lib/tiger/tiger_semant.ml b/compiler/src/lib/tiger/tiger_semant.ml index ca4b489..5d5d71b 100644 --- a/compiler/src/lib/tiger/tiger_semant.ml +++ b/compiler/src/lib/tiger/tiger_semant.ml @@ -135,8 +135,18 @@ end = struct return_unit | A.LetExp {decs=_; body=_; _} -> unimplemented () - | A.ArrayExp {typ=_; size=_; init=_; _} -> - unimplemented () + | A.ArrayExp {typ; size; init; pos} -> + check_int (trexp size) ~pos; + let ty = env_get_typ ~sym:typ ~env ~pos in + Type.if_array + ty + ~f:(fun ty_elements -> + check_same {exp=(); ty=ty_elements} (trexp init) ~pos + ) + ~otherwise:(fun () -> + E.raise (E.Wrong_type_used_as_array {ty_id=typ; ty; pos}) + ); + return ty | A.VarExp var -> trvar var )