Skip to content

Commit 05b7eb6

Browse files
committed
Make the typechecker check that dynamically sized arguments are passed by alias
Before, this would cause an assertion failure in trans.
1 parent c3015b8 commit 05b7eb6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/comp/middle/typeck.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,17 @@ mod collect {
527527
fn ty_of_arg(@ctxt cx, &ast::arg a) -> ty::arg {
528528
auto ty_mode = ast_mode_to_mode(a.mode);
529529
auto f = bind getter(cx, _);
530-
ret rec(mode=ty_mode, ty=ast_ty_to_ty(cx.tcx, f, a.ty));
530+
auto tt = ast_ty_to_ty(cx.tcx, f, a.ty);
531+
if (ty::type_has_dynamic_size(cx.tcx, tt)) {
532+
alt (ty_mode) {
533+
case (mo_val) {
534+
cx.tcx.sess.span_err(a.ty.span,
535+
"Dynamically sized arguments must be passed by alias");
536+
}
537+
case (_) { }
538+
}
539+
}
540+
ret rec(mode=ty_mode, ty=tt);
531541
}
532542

533543
fn ty_of_method(@ctxt cx, &@ast::method m) -> ty::method {

0 commit comments

Comments
 (0)