Skip to content

Commit

Permalink
Merge pull request #823 from summivox/yield-callable
Browse files Browse the repository at this point in the history
fix: `yield` expression should be callable
  • Loading branch information
vendethiel committed Feb 1, 2016
2 parents 7816af0 + fade767 commit 856ab6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/ast.ls
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,8 @@ class exports.Yield extends Node

show: -> if @op is 'yieldfrom' then 'from' else ''

::delegate <[ isCallable ]> -> yes

compile-node: (o) ->
code = []

Expand Down
6 changes: 5 additions & 1 deletion test/generators.ls
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,16 @@ g5.next!
g5.next true
g5.next false

# calling a yield
# yield expression as argument, as callable
is-two = -> it == 2
f6 = ->*
is-two yield 1
ok (yield 1)(2)
ok (2 |> yield 1)
g6 = f6!
eq 1 g6.next(2).value
g6.next is-two
g6.next is-two

# in switch
f7 = (x) ->*
Expand Down

0 comments on commit 856ab6b

Please sign in to comment.