syntax: Fix lambda parsing following 'ret'

This commit is contained in:
Brian Anderson 2012-06-30 21:20:36 -07:00
parent 45ccaf04c4
commit 3155d170ad
2 changed files with 7 additions and 0 deletions

View file

@ -198,6 +198,8 @@ pure fn can_begin_expr(t: token) -> bool {
BINOP(MINUS) { true }
BINOP(STAR) { true }
BINOP(AND) { true }
BINOP(OR) { true } // in lambda syntax
OROR { true } // in lambda syntax
MOD_SEP { true }
_ { false }
}

View file

@ -4,6 +4,10 @@ fn f(i: int, f: fn(int) -> int) -> int { f(i) }
fn g(g: fn()) { }
fn ff() -> fn@(int) -> int {
ret |x| x + 1;
}
fn main() {
assert f(10, |a| a) == 10;
g(||());
@ -11,4 +15,5 @@ fn main() {
do g() || { }
let _x: fn@() -> int = || 10;
let _y: fn@(int) -> int = |a| a;
assert ff()(10) == 11;
}