Skip to content

Commit fc8b515

Browse files
committed
rustboot: If the user tries to instantiate a non-parametric type with type parameters, report the location of the error
1 parent 6ec402d commit fc8b515

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/boot/me/resolve.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,11 @@ let rec lookup_type_by_name
324324
log cx "args: %s"
325325
(Fmt.fmt_to_str Ast.fmt_app_args args);
326326
end;
327-
let ty = rebuild_ty_under_params cx None ty params args true in
327+
let ty =
328+
rebuild_ty_under_params
329+
~node_id:(id_of_scope (List.hd scopes))
330+
cx None ty params args true
331+
in
328332
iflog cx (fun _ -> log cx "--- lookup_type_by_name %a ==> %a"
329333
Ast.sprintf_name name
330334
Ast.sprintf_ty ty);

src/boot/me/semant.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,7 @@ let rec pretty_ty_str (cx:ctxt) (fallback:(Ast.ty -> string)) (ty:Ast.ty) =
10431043
;;
10441044

10451045
let rec rebuild_ty_under_params
1046+
?node_id:id_opt
10461047
(cx:ctxt)
10471048
(src_tag:Ast.ty_tag option)
10481049
(ty:Ast.ty)
@@ -1052,7 +1053,7 @@ let rec rebuild_ty_under_params
10521053
: Ast.ty =
10531054
if (Array.length params) <> (Array.length args)
10541055
then
1055-
err None
1056+
err id_opt
10561057
"mismatched type-params: %s has %d param(s) but %d given"
10571058
(pretty_ty_str cx (Ast.sprintf_ty ()) ty)
10581059
(Array.length params)

0 commit comments

Comments
 (0)