Brian Anderson [Wed, 18 May 2011 00:35:37 +0000 (20:35 -0400)]
rustc: Run block cleanups on else if blocks
With the scheme used to translate 'else if' currently the if expression is
translated in a new (else) scope context. If that if expression wants to
result in a value that requires refcounting then it will need to drop the
refcount in the cleanups of the else block.
Brian Anderson [Sun, 15 May 2011 05:51:31 +0000 (01:51 -0400)]
Return a better result from blocks. Closes issue #377
Blocks return in a copy of the result of their ending expression, not the
direct result of the ending expression, as that may be a local variable which
gets zeroed by drop_slot.
Tim Chevalier [Mon, 16 May 2011 21:33:22 +0000 (14:33 -0700)]
Fix get_os and get_arch
get_os and get_arch were failing to return a value in the error
case; they were also assuming that strings are indexed from 1. No
idea how they ever worked, but anyway, fixed.
Tim Chevalier [Sun, 15 May 2011 02:02:30 +0000 (19:02 -0700)]
Started adding support for return checking and non-returning function annotations
* Reorganized typestate into several modules.
* Made typestate check that any function with a non-nil return type
returns a value. For now, the check is a warning and not an error
(see next item).
* Added a "bot" type (prettyprinted as _|_), for constructs like be, ret, break, cont, and
fail that don't locally return a value that can be inspected. "bot"
is distinct from "nil". There is no concrete syntax for _|_, while
the concrete syntax for the nil type is ().
* Added support to the parser for a ! annotation on functions whose
result type is _|_. Such a function is required to have either a
fail or a call to another ! function that is reached in all control
flow paths. The point of this annotation is to mark functions like
unimpl() and span_err(), so that an alt with a call to err() in one
case isn't a false positive for the return-value checker. I haven't
actually annotated anything with it yet.
* Random bugfixes:
* * Fixed bug in trans::trans_binary that was throwing away the
cleanups for nested subexpressions of an and or or
(tests: box-inside-if and box-inside-if2).
** In typeck, unify the expected type arguments of a tag with the
actual specified arguments.
Brian Anderson [Sun, 15 May 2011 23:53:06 +0000 (19:53 -0400)]
rustc: Wait until generic glue is actually emitted to define it as internal
The verifier was not liking this when generating unoptimized bitcode. Per LLVM
docs it is not valid for function declarations to be marked internal, but
their implementations may be.
Lindsey Kuper [Fri, 13 May 2011 23:35:22 +0000 (16:35 -0700)]
More anon obj work; whitespace police in middle::fold
Passing args to middle::fold::fold_expr_anon_obj by reference to be
consistent with the other folds; adding a dummy fold_expr_anon_obj to
typeck to be filled in later.
Marijn Haverbeke [Fri, 13 May 2011 19:57:34 +0000 (21:57 +0200)]
Remove reserved word tests (since reserved words were removed)
Ping me if you disagree, but I think that in a language that's as
in-flux as rust currently is, it is silly to try and enforce a single
future-compatibility. The reserved words didn't work well with the
parser refactor, so I dropped them for the time being. We can,
eventually, bring them back as type-only reserved words.
Marijn Haverbeke [Fri, 13 May 2011 19:54:32 +0000 (21:54 +0200)]
Safeguard against using statement or item keywords as value ids
This prevents insane things like 'auto while = 2', which would parse
in the previous revision, but then break when you tried to mutate it
with 'while = 10'.
Marijn Haverbeke [Fri, 13 May 2011 19:30:08 +0000 (21:30 +0200)]
Make the parser more careful about keywords
Keywords are now only recognized in contexts where they are valid. The
lexer no longer recognizes them, all words are lexed as IDENT tokens,
that get interpreted by the parser.