You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rubygem-contracts/rubygem-contracts-0.16.0-00...

31 lines
1.1 KiB

From ab30dab081c4e004812eab00a36c70e5b8e4e29b Mon Sep 17 00:00:00 2001
From: md-work <>
Date: Thu, 14 Dec 2017 11:37:18 +0100
Subject: [PATCH 4/5] Wrapping &blocks only when there is a Func check. (bug
278)
---
lib/contracts/call_with.rb | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/contracts/call_with.rb b/lib/contracts/call_with.rb
index c9336a1..9252c79 100644
--- a/lib/contracts/call_with.rb
+++ b/lib/contracts/call_with.rb
@@ -81,8 +81,10 @@ module Contracts
method.call(*args, &blk)
else
# original method name reference
- added_block = blk ? lambda { |*params| blk.call(*params) } : nil
- method.send_to(this, *args, &added_block)
+ # Don't reassign blk, else Travis CI shows "stack level too deep".
+ target_blk = blk
+ target_blk = lambda { |*params| blk.call(*params) } if blk && blk.is_a?(Contract)
+ method.send_to(this, *args, &target_blk)
end
unless @ret_validator[result]
--
2.29.2