``` diff --git a/core/src/main/java/org/jruby/ir/targets/JVMVisitor.java b/core/src/main/java/org/jruby/ir/targets/JVMVisitor.java index 28b8377a27..1be05afe04 100644 --- a/core/src/main/java/org/jruby/ir/targets/JVMVisitor.java +++ b/core/src/main/java/org/jruby/ir/targets/JVMVisitor.java @@ -100,12 +100,13 @@ public class JVMVisitor extends IRVisitor { lastLine = -1; Class result = jrubyClassLoader.defineClass(c(JVM.scriptToClass(file)), code); - for (Map.Entry entry : staticScopeMap.entrySet()) { - try { - result.getField(entry.getKey()).set(null, entry.getValue()); - } catch (Exception e) { - throw new NotCompilableException(e); - } + // only set field for top-level scope because it's passed in + // FIXME: don't pass in and prepare like any other scope + try { + StaticScope staticScope = scope.getStaticScope(); + result.getField(scopeFieldMap.get(staticScope)).set(null, staticScope); + } catch (Exception e) { + throw new NotCompilableException(e); } return result; ```