|
|
@@ -34,13 +34,18 @@ let spec = function
|
|
|
| ArrayDims (ctype, dims) -> (ctype, List.length dims)
|
|
|
| ctype -> (ctype, 0)
|
|
|
|
|
|
+let type2str_error = function
|
|
|
+ | ArrayDims (ctype, dims) ->
|
|
|
+ type2str ctype ^ "[" ^ repeat "," (List.length dims - 1) ^ "]"
|
|
|
+ | ctype ->
|
|
|
+ type2str ctype
|
|
|
+
|
|
|
let check_type ?(msg="") expected node =
|
|
|
let got = typeof node in
|
|
|
if (spec got) <> (spec expected) then begin
|
|
|
let msg = match msg with
|
|
|
| "" -> sprintf "type mismatch: expected type %s, got %s"
|
|
|
- (type2str expected) (type2str got)
|
|
|
- (*(type2str (spec expected)) (type2str (spec got))*)
|
|
|
+ (type2str_error expected) (type2str_error got)
|
|
|
| _ -> msg
|
|
|
in raise (NodeError (node, msg))
|
|
|
end
|