On 2013-09-25, at 17:29 , Patrick Walton wrote:
> 
>> Multiple return values
>> if has a function like this:
>> 
>> fn addsub(x : int, y : int) -> (int, int) {
>>      return (x+y,x-y);
>> }
>> 
>> them, this is valid:
>> 
>> let (b,c) = addsub(x, y);
>> 
>> but this is invalid;
>> 
>> let b:int =0;
>> let c:int =0;
>> (b,c) = addsub(x, y);
>> 
>> also invalid:
>> 
>> let (b,c)  = (0, 0);
>> (b,c) = addsub(x, y);
> 
> If we did this, we wouldn't know whether to parse a pattern or an
> expression when starting a statement. This isn't fixable without trying
> to define some sort of cover grammar that covers both expressions and
> patterns, like ECMAScript 6 does. I don't know if this would work in
> Rust.

There seems to be a bug somewhere though, ignoring that the bindings are
not mut in the example (making them immutable unless that's changed
recently) the compiler freaks out quite a bit:

test.rs:8:4: 8:10 error: internal compiler error: trans_lvalue reached
fall-through case: expr_tup(~[@{id: 38, node: expr_path(@{span: {lo:
{__field__: 121}, hi: {__field__: 122}, expn_info: None}, global: false,
idents: ~[{name: 70, ctxt: 0}], rp: None, types: ~[]}), span: {lo:
{__field__: 121}, hi: {__field__: 122}, expn_info: None}}, @{id: 39,
node: expr_path(@{span: {lo: {__field__: 124}, hi: {__field__: 125},
expn_info: None}, global: false, idents: ~[{name: 71, ctxt: 0}], rp:
None, types: ~[]}), span: {lo: {__field__: 124}, hi: {__field__: 125},
expn_info: None}}])
test.rs:8 (b, c) = addsub(1, 2);

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to