Skip to content

Commit 54587cc

Browse files
committed
Correctly handle begin as kw in typed comprehension
1 parent 7951c0e commit 54587cc

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/parser.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2525,6 +2525,7 @@ end
25252525
# then reconstructing the nested flattens and generators when converting to Expr.
25262526
#
25272527
# [x for a = as for b = bs if cond1 for c = cs if cond2] ==> (comprehension (flatten x (= a as) (filter (= b bs) cond1) (filter (= c cs) cond2)))
2528+
# [x for a = as if begin cond2 end] => (comprehension (generator x (filter (= a as) (block cond2))))
25282529
#
25292530
# flisp: parse-generator
25302531
function parse_generator(ps::ParseState, mark, flatten=false)
@@ -2561,7 +2562,8 @@ end
25612562
# flisp: parse-comprehension
25622563
function parse_comprehension(ps::ParseState, mark, closer)
25632564
ps = ParseState(ps, whitespace_newline=true,
2564-
space_sensitive=false)
2565+
space_sensitive=false,
2566+
end_symbol=false)
25652567
parse_generator(ps, mark)
25662568
bump_closing_token(ps, closer)
25672569
return (K"comprehension", EMPTY_FLAGS)

test/parser.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ tests = [
614614
"[x \n\n for a in as]" => "(comprehension (generator x (= a as)))"
615615
# parse_generator
616616
"[x for a = as for b = bs if cond1 for c = cs if cond2]" => "(comprehension (flatten x (= a as) (filter (= b bs) cond1) (filter (= c cs) cond2)))"
617+
"[x for a = as if begin cond2 end]" => "(comprehension (generator x (filter (= a as) (block cond2))))"
617618
"[(x)for x in xs]" => "(comprehension (generator x (error-t) (= x xs)))"
618619
"(a for x in xs if cond)" => "(generator a (filter (= x xs) cond))"
619620
"(xy for x in xs for y in ys)" => "(flatten xy (= x xs) (= y ys))"

0 commit comments

Comments
 (0)