Skip to content

Commit cbebf5c

Browse files
committed
Clarify condition for block_given? desugar
Checking the `enclosingBlockParamName` was really just a proxy for whether we were in a method or not. Even for methods with no explicit block parameter, `buildMethod()`, will add a synthetic `&<blk>`, so the if we're in a method, `enclosingBlockParamName` is always set by the time it's checked here.
1 parent c247f9a commit cbebf5c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ast/desugar/Desugar.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ ExpressionPtr node2TreeImplBody(DesugarContext dctx, parser::Node *what) {
748748
flags.isPrivateOk = true;
749749
}
750750

751-
if (isCallToBlockGivenP(send, rec) && dctx.enclosingBlockParamName.exists()) {
751+
if (isCallToBlockGivenP(send, rec) && dctx.enclosingMethodLoc.exists()) {
752752
// Desugar:
753753
// def foo(&my_block)
754754
// x = block_given?

ast/desugar/PrismDesugar.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ ExpressionPtr node2TreeImplBody(DesugarContext dctx, parser::Node *what) {
732732
flags.isPrivateOk = true;
733733
}
734734

735-
if (isCallToBlockGivenP(send, rec) && dctx.enclosingBlockParamName.exists()) {
735+
if (isCallToBlockGivenP(send, rec) && dctx.enclosingMethodLoc.exists()) {
736736
// Desugar:
737737
// def foo(&my_block)
738738
// x = block_given?

0 commit comments

Comments
 (0)