From: Patrick Walton Date: Fri, 10 Jun 2011 17:53:42 +0000 (-0700) Subject: Merge pull request #447 from paulstansifer/quick_error_message_fix X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=7b7c746c1e92fe9fa50a94396dfe5efae0034df9;p=rust.git Merge pull request #447 from paulstansifer/quick_error_message_fix Error message, instead of segfault, when recursive types are used. --- 7b7c746c1e92fe9fa50a94396dfe5efae0034df9 diff --cc src/comp/middle/typeck.rs index 289691444b0,0c21090d6e4..cf99f1ab4b1 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@@ -219,12 -227,22 +219,22 @@@ fn type_is_scalar(&@fn_ctxt fcx, &span // notion of a type. `getter` is a function that returns the type // corresponding to a definition ID: fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t { + alt (tcx.ast_ty_to_ty_cache.find(ast_ty)) { + case (some[option::t[ty::t]](some[ty::t](?ty))) { ret ty; } + case (some[option::t[ty::t]](none)) { + tcx.sess.span_err(ast_ty.span, "illegal recursive type " + + "(insert a tag in the cycle, if this is desired)"); + } + case (none[option::t[ty::t]]) { } /* go on */ + } + tcx.ast_ty_to_ty_cache.insert(ast_ty, none[ty::t]); + fn ast_arg_to_arg(&ty::ctxt tcx, &ty_getter getter, - &rec(ast::mode mode, @ast::ty ty) arg) + &ast::ty_arg arg) -> rec(ty::mode mode, ty::t ty) { - auto ty_mode = ast_mode_to_mode(arg.mode); - ret rec(mode=ty_mode, ty=ast_ty_to_ty(tcx, getter, arg.ty)); + auto ty_mode = ast_mode_to_mode(arg.node.mode); + ret rec(mode=ty_mode, ty=ast_ty_to_ty(tcx, getter, arg.node.ty)); } fn ast_mt_to_mt(&ty::ctxt tcx,