Skip to content

Commit 1bd58df

Browse files
author
md-work
committed
Wrapping &blocks only when there is a Func check. (bug 278)
1 parent da2ad64 commit 1bd58df

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/contracts/call_with.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ def call_with_inner(returns, this, *args, &blk)
8181
method.call(*args, &blk)
8282
else
8383
# original method name reference
84-
added_block = blk ? lambda { |*params| blk.call(*params) } : nil
85-
method.send_to(this, *args, &added_block)
84+
# Don't reassign blk, else Travis CI shows "stack level too deep".
85+
target_blk = blk
86+
target_blk = lambda { |*params| blk.call(*params) } if blk && blk.is_a?(Contract)
87+
method.send_to(this, *args, &target_blk)
8688
end
8789

8890
unless @ret_validator[result]

0 commit comments

Comments
 (0)