diff options
| author | Patrick Walton <[email protected]> | 2010-10-21 11:31:04 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2010-10-21 11:31:04 -0700 |
| commit | 194f38fdff2b2067413b6eabf3d6da57fbba2dc1 (patch) | |
| tree | eb27acb9f91d526f4e4a6a3097a56c778dd94004 | |
| parent | Use "friendly" type names when reporting a "mismatched type-params" error (diff) | |
| download | rust-194f38fdff2b2067413b6eabf3d6da57fbba2dc1.tar.xz rust-194f38fdff2b2067413b6eabf3d6da57fbba2dc1.zip | |
rustboot: Don't use ridiculous type names when describing simple types like int and uint
| -rw-r--r-- | src/boot/fe/ast.ml | 11 | ||||
| -rw-r--r-- | src/boot/me/semant.ml | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/boot/fe/ast.ml b/src/boot/fe/ast.ml index 78b3ac51..f81f614f 100644 --- a/src/boot/fe/ast.ml +++ b/src/boot/fe/ast.ml @@ -516,6 +516,17 @@ let sane_name (n:name) : bool = | NAME_ext (prefix, _) -> sane_prefix prefix ;; +(* Error messages always refer to simple types structurally, not by their + * user-defined names. *) +let rec ty_is_simple (ty:ty) : bool = + match ty with + TY_any | TY_nil | TY_bool | TY_mach _ | TY_int | TY_uint | TY_char + | TY_str | TY_task | TY_type -> true + | TY_vec ty | TY_chan ty | TY_port ty -> ty_is_simple ty + | TY_tup tys -> List.for_all ty_is_simple (Array.to_list tys) + | _ -> false +;; + (* * We have multiple subset-categories of expression: * diff --git a/src/boot/me/semant.ml b/src/boot/me/semant.ml index 0bb6a8bb..4f278d12 100644 --- a/src/boot/me/semant.ml +++ b/src/boot/me/semant.ml @@ -971,7 +971,7 @@ let ty_fold_rebuild (id:Ast.ty -> Ast.ty) let rec pretty_ty_str (cx:ctxt) (fallback:(Ast.ty -> string)) (ty:Ast.ty) = let cache = cx.ctxt_user_type_names in - if Hashtbl.mem cache ty then + if not (Ast.ty_is_simple ty) && Hashtbl.mem cache ty then let names = List.map (Ast.sprintf_name ()) (Hashtbl.find_all cache ty) in String.concat " = " names else |