rust/src
Tim Chevalier d7ee55bfd0 (Almost) Always unify a function tail expr with the function result type
typeck::check_fn had an exception for the case where the tail expr
was compatible with type nil -- in that case, it doesn't unify the
tail expr's type with the enclosing function's result type. This
seems wrong to me. There are several test cases in Issue #719
that illustrate why. If the tail expr has type T, for some type
variable T that isn't resolved when this check happens, then T
never gets unified with anything, which is incorrect -- T should
be unified with the result type of the enclosing function. (The
bug was occurring because an unconstrained type variable is
compatible with type nil.)

Instead, I removed the check for type nil and added a check that
the function isn't an iterator -- if it's an iterator, I don't
check the tail expr's type against the function result type,
as that wouldn't make sense.

However, this broke two test cases, and after discussion with
brson, I understood that the purpose of the check was to allow
semicolons to be omitted in some cases. The whole thing seems
rather ad hoc. But I came up with a hacky compromise solution:
instead of checking whether the tailexpr type is *compatible*
with nil, we now just check whether it *is* nil. This also
necessitates calling resolve_type_vars_if_possible before
the check happens, which worries me. But, this fixes the bug
from Issue #719 without requiring changes to any test cases.

Closes #719 but I didn't try every variation -- so reopen the bug
if one of the variations still doesn't work.
2011-08-05 02:21:58 -07:00
..
comp (Almost) Always unify a function tail expr with the function result type 2011-08-05 02:21:58 -07:00
etc Make combine-tests ignore temp files 2011-07-28 14:24:20 -07:00
fuzzer parse_crate_from_source_str takes a parse_sess, not codemap 2011-08-03 10:55:59 -07:00
lib stdlib: Pass getopt matches by alias 2011-08-04 17:11:50 -07:00
rt rt: Change int to uint32_t. Put out burning tinderbox. 2011-08-04 09:50:11 -07:00
rustllvm Revert "Revert "Rename Passes2.cpp to Passes.cpp"" 2011-07-17 19:16:23 -07:00
test (Almost) Always unify a function tail expr with the function result type 2011-08-05 02:21:58 -07:00
README Update README files 2011-06-26 22:27:22 -07:00
snapshots.txt Registering snapshot. 2011-08-04 11:06:11 -07:00

This is preliminary version of the Rust compiler(s).

Source layout:

comp/              The self-hosted compiler

lib/               The standard library

rustllvm/          LLVM support code

rt/                The runtime system
rt/rust_*.cpp      - The majority of the runtime services
rt/isaac           - The PRNG used for pseudo-random choices in the runtime
rt/bigint          - The bigint library used for the 'big' type
rt/uthash          - Small hashtable-and-list library for C, used in runtime
rt/{sync,util}     - Small utility classes for the runtime.

test/              Testsuite
test/compile-fail  - Tests that should fail to compile
test/run-fail      - Tests that should compile, run and fail
test/run-pass      - Tests that should compile, run and succeed
test/bench         - Benchmarks and miscellanea

Please be gentle, it's a work in progress.