From 81ecde07d4ad538affec04f2df26cfa3f7aacbbe Mon Sep 17 00:00:00 2001 From: summivox Date: Mon, 25 Jan 2016 01:29:36 -0500 Subject: [PATCH 1/2] fix: `yield` expression should be callable --- src/ast.ls | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ast.ls b/src/ast.ls index ca16730bf..6296f5c68 100644 --- a/src/ast.ls +++ b/src/ast.ls @@ -1124,6 +1124,8 @@ class exports.Yield extends Node show: -> if @op is 'yieldfrom' then 'from' else '' + ::delegate <[ isCallable ]> -> yes + compile-node: (o) -> code = [] From fade767faad2deb94eaeb4daa6eb3fc34ed8abfd Mon Sep 17 00:00:00 2001 From: summivox Date: Sun, 31 Jan 2016 17:55:30 -0500 Subject: [PATCH 2/2] add test for callable yield expression --- test/generators.ls | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/generators.ls b/test/generators.ls index badf3ce1f..fbb20dd31 100644 --- a/test/generators.ls +++ b/test/generators.ls @@ -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) ->*