diff options
| author | Patrick Walton <[email protected]> | 2010-11-29 17:11:03 -0800 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2010-11-29 17:11:41 -0800 |
| commit | 6c5a05b819c4dc7e3c47056a61a27fa4f11a364f (patch) | |
| tree | f0f8e89877aceb4bb1c906925c270d38c01be372 /src/comp/middle/fold.rs | |
| parent | Teach fold about ty_rec. (diff) | |
| download | rust-6c5a05b819c4dc7e3c47056a61a27fa4f11a364f.tar.xz rust-6c5a05b819c4dc7e3c47056a61a27fa4f11a364f.zip | |
rustc: Implement the block syntax discussed on the mailing list
Diffstat (limited to 'src/comp/middle/fold.rs')
| -rw-r--r-- | src/comp/middle/fold.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/comp/middle/fold.rs b/src/comp/middle/fold.rs index ff8f5505..c97dceb4 100644 --- a/src/comp/middle/fold.rs +++ b/src/comp/middle/fold.rs @@ -529,7 +529,19 @@ fn fold_block[ENV](&ENV env, ast_fold[ENV] fld, &block blk) -> block { for (@ast.stmt s in blk.node.stmts) { append[@ast.stmt](stmts, fold_stmt[ENV](env_, fld, s)); } - ret respan(blk.span, rec(stmts=stmts with blk.node)); + + auto expr = none[@ast.expr]; + alt (blk.node.expr) { + case (some[@ast.expr](?e)) { + expr = some[@ast.expr](fold_expr[ENV](env_, fld, e)); + } + case (none[@ast.expr]) { + // empty + } + } + + // FIXME: should we reindex? + ret respan(blk.span, rec(stmts=stmts, expr=expr, index=blk.node.index)); } fn fold_arg[ENV](&ENV env, ast_fold[ENV] fld, &arg a) -> arg { |