(The old syntax is still supported as well, for now.)
It is now possible to leave out the parens around if, while, and
do/while conditions, and around alt expressions. Cases in an alt block
can now leave off the case keyword and parens around the pattern.
After the next snapshot, we can start migrating our code to use the
new alt syntax, probably with a pretty-printer pass. The paren-free
syntax will remain optional (you may always parenthesize expressions),
but the old case syntax will no longer be supported in the future.
If a closure inside a case alternative (for example, a for each loop)
referenced a pattern-bound variable, this would cause an assertion
failure in trans. Changed trans::collect_upvars to handle pattern-bound
vars correctly.
Incidentally, eliminated all direct uses of option::get in trans.
Add a failure checkpoint after the typechecking pass. There are still many
fatal errors in typeck, but loosening up this one makes it easier to lean on
the compiler when making changes to types.
Issue #440.
The tinderbox snapshotting scripts seem to be looking for a stage2-check
target when they should be using check-stage2. Since Graydon is out of the
office, I'm making this change to see if the snapshot will go through.
src/comp/syntax is currently just a sub-module of rustc, but it will,
in the near future, be its own crate. This includes:
- The AST data structure
- The parser
- The pretty-printer
- Visit, walk, and fold
- The syntax extension system
- Some utility stuff that should be in the stdlib*
*) Stdlib extensions currently require a snapshot before they can be
used, and the win build is very broken right now. This is temporary
and will be cleaned up when one of those problems goes away.
A lot of code was moved by this patch, mostly towards a more organized
layout. Some package paths did get longer, and I guess the new layout
will take some getting used to. Sorry about that!
Please try not to re-introduce any dependencies in syntax/ on any of
the other src/comp/ subdirs.
This way, the pretty-printer does not have to know about middle::ty.
(This is a preparation for separating the AST functionality into a
separate crate.)
An expression like:
foo(1, fail, 2)
was failing to parse, because the parser was interpreting the comma
as the start of an expression that was an argument to fail, rather
than recognizing that the fail here has no arguments
Fixed this by using can_begin_expr to determine whether the next
token after a fail token suggests that this is a nullary fail or a
unary fail.
In addition, when translating calls, check before translating each
argument that the block still isn't terminated. This has the effect
that if an argument list includes fail, the back-end won't keep trying
to generate code for successive arguments and trip the !*terminated
assertion.