Swap the expected/actual for typechecking fields of updated records
In 'rec(a = b with c)', if a exists in c then the expected type for b is the type of c.
This commit is contained in:
parent
05954f37b7
commit
0eac640fdd
src
@ -2120,8 +2120,8 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||
auto found = false;
|
||||
for (ty::field bf in base_fields) {
|
||||
if (str::eq(f.ident, bf.ident)) {
|
||||
demand::simple(fcx, expr.span, f.mt.ty,
|
||||
bf.mt.ty);
|
||||
demand::simple(fcx, expr.span, bf.mt.ty,
|
||||
f.mt.ty);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
9
src/test/compile-fail/rec-extend.rs
Normal file
9
src/test/compile-fail/rec-extend.rs
Normal file
@ -0,0 +1,9 @@
|
||||
// xfail-stage0
|
||||
// error-pattern:expected int but found bool
|
||||
|
||||
fn main() {
|
||||
|
||||
auto a = rec(foo = 0);
|
||||
|
||||
auto b = rec(foo = true with a);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user