Skip to content

Commit b292d8b

Browse files
committed
[GR-27300] Backport topScope fix.
PullRequest: truffleruby/2149
2 parents d2d8607 + dffec89 commit b292d8b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/main/java/org/truffleruby/debug/TopScopeObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void removeMember(String member,
227227
@Shared("interop") @CachedLibrary(limit = "LIMIT") InteropLibrary interop)
228228
throws UnsupportedMessageException, UnknownIdentifierException {
229229
int length = NAMES.length;
230-
for (int i = 0; i < length; i++) {
230+
for (int i = scopeIndex; i < length; i++) {
231231
Object scope = this.objects[i];
232232
if (interop.isMemberRemovable(scope, member)) {
233233
interop.removeMember(scope, member);

src/test/java/org/truffleruby/PolyglotInteropTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved. This
2+
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved. This
33
* code is released under a tri EPL/GPL/LGPL license. You can use it,
44
* redistribute it and/or modify it under the terms of the:
55
*
@@ -218,4 +218,18 @@ public void testTopScopes() {
218218
assertEquals(formatMethod.execute("hello").asString(), "hello");
219219
}
220220
}
221+
222+
@Test
223+
//GR-27300
224+
public void testTopScopeRemoveBindings() {
225+
try (Context context = Context.create()) {
226+
Value bindings = context.getBindings("ruby");
227+
228+
assertFalse(bindings.hasMember("@foo"));
229+
context.eval("ruby", "@foo=42;");
230+
assertTrue(bindings.hasMember("@foo"));
231+
assertTrue(bindings.removeMember("@foo"));
232+
assertFalse(bindings.hasMember("@foo"));
233+
}
234+
}
221235
}

0 commit comments

Comments
 (0)