syntax: Fix lambda parsing following 'ret'
This commit is contained in:
parent
45ccaf04c4
commit
3155d170ad
2 changed files with 7 additions and 0 deletions
|
@ -198,6 +198,8 @@ pure fn can_begin_expr(t: token) -> bool {
|
||||||
BINOP(MINUS) { true }
|
BINOP(MINUS) { true }
|
||||||
BINOP(STAR) { true }
|
BINOP(STAR) { true }
|
||||||
BINOP(AND) { true }
|
BINOP(AND) { true }
|
||||||
|
BINOP(OR) { true } // in lambda syntax
|
||||||
|
OROR { true } // in lambda syntax
|
||||||
MOD_SEP { true }
|
MOD_SEP { true }
|
||||||
_ { false }
|
_ { false }
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,10 @@ fn f(i: int, f: fn(int) -> int) -> int { f(i) }
|
||||||
|
|
||||||
fn g(g: fn()) { }
|
fn g(g: fn()) { }
|
||||||
|
|
||||||
|
fn ff() -> fn@(int) -> int {
|
||||||
|
ret |x| x + 1;
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
assert f(10, |a| a) == 10;
|
assert f(10, |a| a) == 10;
|
||||||
g(||());
|
g(||());
|
||||||
|
@ -11,4 +15,5 @@ fn main() {
|
||||||
do g() || { }
|
do g() || { }
|
||||||
let _x: fn@() -> int = || 10;
|
let _x: fn@() -> int = || 10;
|
||||||
let _y: fn@(int) -> int = |a| a;
|
let _y: fn@(int) -> int = |a| a;
|
||||||
|
assert ff()(10) == 11;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue