Commit graph

391 commits

Author SHA1 Message Date
Graydon Hoare
2561b01211 Remove residual uses of fold, and fold itself. 2011-05-26 17:16:54 -07:00
Brian Anderson
29a801565a rustc: Fail better when the first argument to #fmt is not a string literal 2011-05-25 23:50:19 -04:00
Brian Anderson
c4e9d8fb91 rustc: Fail when #fmt is given too many arguments 2011-05-25 23:43:04 -04:00
Marijn Haverbeke
86d51ec24b Get test-pass/utf8.rs to run
This involved a small fix to the unicode-escape character lexing and
to the pretty-printer.
2011-05-23 23:25:55 +02:00
Tim Chevalier
467b938ea8 Merge remote-tracking branch 'graydon/master' into typestate_4 2011-05-20 18:23:03 -07:00
Tim Chevalier
fed0486c33 Annotate erroring functions in session and parser 2011-05-20 18:20:54 -07:00
Lindsey Kuper
c3410bf927 More work on anonymous objects. 2011-05-20 17:59:56 -07:00
Tim Chevalier
a08a376d6e Make controlflow part of a function type
Change ty_fn to have a controlflow field. A 'controlflow' is
essentially a bit of data that says whether or not this function
never returns to the caller (if it never returns, that means it calls
"fail" or another "never-returns" function on every control path).

Also add syntax for annotating functions that never return:

fn foo() -> ! {
   fail;
}

for example. Functions marked with ! implicitly have a result type of
ty_bot, which is a new type that this commit also adds.
2011-05-20 16:57:37 -07:00
Patrick Walton
7e43a31f08 rustc: Move the interner to a new module intended to be used for general data structures 2011-05-20 13:57:53 -07:00
Graydon Hoare
7f938f4945 Move the ty_item_table into ty::ctxt.items, move variant_info to ty, and start sketching the contains_pointer property on types. 2011-05-19 17:21:36 -07:00
Marijn Haverbeke
8a7b544995 Finish name collision testing.
And fix a the single screw-up in the source code it caught.
2011-05-19 21:58:57 +02:00
Tim Chevalier
bb594a03a1 remove now-unused ts field from ann 2011-05-19 11:40:16 -07:00
Patrick Walton
5047ab0b0c rustc: Flatten annotations 2011-05-17 13:55:32 -07:00
Marijn Haverbeke
a90df393f9 Alias-ify the parser and lexer
This only shaves a measly 19k off the rustc binary... but hey, every
little thing helps.
2011-05-17 20:45:49 +02:00
Marijn Haverbeke
09d8ef8d51 Finally rename std::_xxx to std::xxx
Except for _task, which is still a keyword.
2011-05-17 20:41:41 +02:00
Paul Stansifer
1fdc75ee7c Parser fix: 'fail' was eating the next token that came after it. 2011-05-17 05:40:17 +00:00
Graydon Hoare
a2e2e78103 Merge remote branch 'origin/master' into HEAD
Conflicts:
	src/comp/middle/trans.rs
2011-05-16 19:04:45 -07:00
Graydon Hoare
fbbc1a77d2 Rewrite everything to use [] instead of vec() in value position. 2011-05-16 18:21:22 -07:00
Graydon Hoare
ae030c5bf2 Begin vec() -> [] transition. 2011-05-16 17:04:12 -07:00
Tim Chevalier
971b5d5151 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.
2011-05-16 16:59:25 -07:00
Patrick Walton
3ea3d9eed6 rustc: Make the parser use the interner 2011-05-16 14:54:10 -07:00
Marijn Haverbeke
b7d6934ef3 fix a long line that i forgot to commit 2011-05-14 13:27:21 +02:00
Marijn Haverbeke
ee45fd80c6 Mark IDENT tokens that are followed by ::
So that the type parser won't go off and try to parse a vec
type when it sees vec::init_op.
2011-05-14 12:57:42 +02:00
Graydon Hoare
6997adf763 Remove rustboot from the repository. 2011-05-13 18:38:28 -07:00
Lindsey Kuper
5679f5c55e 'with' no longer a token; whitespace police.
Plus renaming the anonymous objects test to a more descriptive name,
and XFAILing it because it doesn't work yet.
2011-05-13 17:37:01 -07:00
Lindsey Kuper
814b17352c Use new module namespace syntax. 2011-05-13 17:35:13 -07:00
Lindsey Kuper
d3242b9644 Bug fixes.
Fixed infinite loop on anonymous objects in parser; added
expr_anon_obj to walk.rs; fixed syntax of test case.
2011-05-13 17:35:13 -07:00
Lindsey Kuper
6c1c5b3948 More progress on anonymous objects.
Still segfaulting on the method-overriding.rs test, though.
2011-05-13 17:35:13 -07:00
Lindsey Kuper
6a53e39e71 Correct capitalization of "Option". 2011-05-13 17:35:12 -07:00
Lindsey Kuper
7c2979e26f Starting on support for anonymous objects. Just syntax so far. 2011-05-13 17:35:12 -07:00
Marijn Haverbeke
571afe71ba 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'.
2011-05-13 22:00:13 +02:00
Marijn Haverbeke
57ffa2a487 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.
2011-05-13 22:00:13 +02:00
Marijn Haverbeke
eb419fd8c7 Extend crate format to allow multiple definitions for a single name
The type/value namespace distinction pretty much works now. Module
namespace is up next.
2011-05-13 17:20:39 +02:00
Marijn Haverbeke
58ec5d1654 Move capture checking into resolve.rs
Drops capture.rs. The new algorithm also checks for captures function
arguments and obj fields.
2011-05-13 12:44:05 +02:00
Brian Anderson
02fdd2d2d9 Rename std.extfmt.CT to std.extfmt.RT to ct and rt
Temporarily duplicate the entire RT module, leaving it with the old name to
accomodate the stage0 compiler. Will be removed after the next snapshot.
2011-05-12 22:22:28 -04:00
Marijn Haverbeke
3816e57fd2 Downcase std modules again, move to :: for module dereferencing
This should be a snapshot transition.
2011-05-12 21:30:44 +02:00
Marijn Haverbeke
b1d3364487 Transitional change to make extfmt output lowercase module name 2011-05-12 21:30:43 +02:00
Marijn Haverbeke
6510f1ce7c Change module dereference syntax from . to ::
This will need to be a snapshot.
2011-05-12 21:30:35 +02:00
Marijn Haverbeke
dd9b6dccb4 Remove some truly wrong logic in parse_constrs 2011-05-12 15:52:12 +02:00
Marijn Haverbeke
358a1aeec9 Keep resolve data in external hash table, rather than embedded defs
One step closer to removing fold and having a single, immutable AST.
Resolve still uses fold, because it has to detect and transform
expr_field expressions. If we go through on our plan of moving to a
different syntax for module dereferencing, the parser can spit out
expr_field expressions, and resolve can move to walk.

(I am truly sorry for the things I did in typestate_check.rs. I expect
we'll want to change that to walk as well in the near future, at which
point it should probably pass around a context record, which could
hold the def_map.)
2011-05-12 15:40:21 +02:00
Marijn Haverbeke
2b36e40c58 Ensure ann tags are actually kept around during typechecking
This way, the tag assigned by the parser stays with the node.
I realize ann replacing is probably going away real soon, but
I needed this now for moving the resolve defs out of the AST.
2011-05-12 10:51:13 +02:00
Marijn Haverbeke
079512494f Properly lex block comments followed by EOF 2011-05-12 09:31:06 +02:00
Brian Anderson
353ed4bdff Remove unused filename parameter from lexer.new_reader 2011-05-11 23:38:20 -04:00
Brian Anderson
a459bcd127 Give the lexer a session so that it can fail more informatively 2011-05-11 23:04:16 -04:00
Marijn Haverbeke
14f1fe0e29 Remove mod indices from the AST
They are now created by the resolve pass, which is the only pass that
needs them, and kept internal to that pass.
2011-05-11 17:11:44 +02:00
Marijn Haverbeke
fe29d24b6e Get rid of arm indices 2011-05-11 15:26:36 +02:00
Marijn Haverbeke
5405f45274 Get rid of block indices 2011-05-11 15:10:24 +02:00
Marijn Haverbeke
7f222423b7 Use a const for crate-num-zero (ast.local_crate) 2011-05-11 12:59:34 +02:00
Marijn Haverbeke
e9c12ab1d0 Rewrite comp/middle/resolve.rs
* Cleans up the algorithm
 * Move first pass to walk (second still folds)
 * Support part of a type/value namespace split
   (crate metadata and module indices still need to be taught about this)
 * Remove a few blatant inefficiencies (import tables being recreated for
   every lookup, most importantly)
2011-05-11 12:32:37 +02:00
Patrick Walton
10c9266525 rustc: Number everything with an annotation 2011-05-10 17:27:59 -07:00