diff options
| author | Rafael Ávila de Espíndola <[email protected]> | 2011-01-19 15:02:56 -0500 |
|---|---|---|
| committer | Rafael Ávila de Espíndola <[email protected]> | 2011-01-19 15:02:56 -0500 |
| commit | d313e1579bd8a78a15cde9b17819aa7cfbf6f8c1 (patch) | |
| tree | 0a05cb036f8f2a78d877f95b6d49ddebf19f58ce /src | |
| parent | Change generic-drop-glue.rs to be meaningful again, and un-XFAIL on rustc. (diff) | |
| download | rust-d313e1579bd8a78a15cde9b17819aa7cfbf6f8c1.tar.xz rust-d313e1579bd8a78a15cde9b17819aa7cfbf6f8c1.zip | |
Fold function output and argument types. With this change we fail to compile
type lteq[T] = fn(&T a) -> bool;
with "unresolved name: T". Before we would silently get to the type checker
and assert in a unresolved ty_path.
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp/middle/fold.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/comp/middle/fold.rs b/src/comp/middle/fold.rs index f81b7a52..618790ee 100644 --- a/src/comp/middle/fold.rs +++ b/src/comp/middle/fold.rs @@ -307,8 +307,7 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty { case (ast.ty_obj(?meths)) { let vec[ast.ty_method] meths_ = vec(); for (ast.ty_method m in meths) { - auto tfn = fld.fold_ty_fn(env_, t.span, - m.inputs, m.output); + auto tfn = fold_ty_fn(env_, fld, t.span, m.inputs, m.output); alt (tfn.node) { case (ast.ty_fn(?ins, ?out)) { append[ast.ty_method] @@ -330,11 +329,24 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty { } case (ast.ty_fn(?inputs, ?output)) { - ret fld.fold_ty_fn(env_, t.span, inputs, output); + ret fold_ty_fn(env_, fld, t.span, inputs, output); } } } +fn fold_ty_fn[ENV](&ENV env, ast_fold[ENV] fld, &span sp, + vec[rec(ast.mode mode, @ty ty)] inputs, + @ty output) -> @ty { + auto output_ = fold_ty(env, fld, output); + let vec[rec(ast.mode mode, @ty ty)] inputs_ = vec(); + for (rec(ast.mode mode, @ty ty) input in inputs) { + auto ty_ = fold_ty(env, fld, input.ty); + auto input_ = rec(ty=ty_ with input); + inputs_ += vec(input_); + } + ret fld.fold_ty_fn(env, sp, inputs_, output_); +} + fn fold_decl[ENV](&ENV env, ast_fold[ENV] fld, @decl d) -> @decl { let ENV env_ = fld.update_env_for_decl(env, d); |