Skip to content

Instantly share code, notes, and snippets.

@headius

headius/.diff Secret

Created March 31, 2021 19:13
Show Gist options
  • Save headius/e3dec8bee3364e2831dbc58bd1493451 to your computer and use it in GitHub Desktop.
Save headius/e3dec8bee3364e2831dbc58bd1493451 to your computer and use it in GitHub Desktop.
diff --git a/core/src/main/java/org/jruby/ir/IRBuilder.java b/core/src/main/java/org/jruby/ir/IRBuilder.java
index 9de004437e..afc2fa908f 100644
--- a/core/src/main/java/org/jruby/ir/IRBuilder.java
+++ b/core/src/main/java/org/jruby/ir/IRBuilder.java
@@ -2398,7 +2398,7 @@ public class IRBuilder {
// used for yields; metaclass body (sclass) inherits yield var from surrounding, and accesses it as implicit
if (scope instanceof IRMethod || scope instanceof IRMetaClassBody) {
addInstr(new LoadImplicitClosureInstr(getYieldClosureVariable()));
- } else {
+ } else if (scope instanceof IRModuleBody || scope instanceof IRClassBody) {
addInstr(new LoadFrameClosureInstr(getYieldClosureVariable()));
}
}
@@ -4146,6 +4146,11 @@ public class IRBuilder {
Variable ret = result == null ? createTemporaryVariable() : result;
Operand value = argNode instanceof ArrayNode && unwrap ? buildArray((ArrayNode)argNode, true) : build(argNode);
+
+ if (!(scope instanceof IRMethod || scope instanceof IRMetaClassBody || scope instanceof IRModuleBody || scope instanceof IRClassBody)) {
+ addInstr(new LoadFrameClosureInstr(getYieldClosureVariable()));
+ }
+
addInstr(new YieldInstr(ret, getYieldClosureVariable(), value, unwrap));
return ret;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment