@@ -234,6 +234,7 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
234
234
}
235
235
236
236
fn instantiate ( & ty:: ctxt tcx,
237
+ & span sp,
237
238
& ty_getter getter,
238
239
& ast:: def_id id,
239
240
& vec[ @ast:: ty] args ) -> ty:: t {
@@ -246,13 +247,18 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
246
247
247
248
// The typedef is type-parametric. Do the type substitution.
248
249
//
249
- // TODO: Make sure the number of supplied bindings matches the number
250
- // of type parameters in the typedef. Emit a friendly error otherwise.
251
250
let vec[ ty:: t] param_bindings = [ ] ;
252
251
for ( @ast:: ty ast_ty in args) {
253
252
param_bindings += [ ast_ty_to_ty ( tcx, getter, ast_ty) ] ;
254
253
}
255
254
255
+ if ( vec:: len ( param_bindings) !=
256
+ ty:: count_ty_params ( tcx, params_opt_and_ty. _1 ) ) {
257
+ tcx. sess . span_err ( sp, "Wrong number of type arguments for a"
258
+ + " polymorphic tag" ) ;
259
+ }
260
+
261
+
256
262
auto typ = ty:: substitute_type_params ( tcx, param_bindings,
257
263
params_opt_and_ty. _1 ) ;
258
264
ret typ;
@@ -315,11 +321,13 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
315
321
case ( ast:: ty_path( ?path, ?ann) ) {
316
322
alt ( tcx. def_map. get( ann. id) ) {
317
323
case ( ast:: def_ty( ?id) ) {
318
- typ = instantiate( tcx, getter, id, path. node. types) ;
324
+ typ = instantiate( tcx, ast_ty. span, getter, id,
325
+ path. node. types) ;
319
326
}
320
327
case ( ast:: def_native_ty( ?id) ) { typ = getter( id) . _1; }
321
328
case ( ast:: def_obj( ?id) ) {
322
- typ = instantiate( tcx, getter, id, path. node. types) ;
329
+ typ = instantiate( tcx, ast_ty. span, getter, id,
330
+ path. node. types) ;
323
331
}
324
332
case ( ast:: def_ty_arg( ?id) ) { typ = ty:: mk_param( tcx, id) ; }
325
333
case ( _) {
0 commit comments