From: "shugo (Shugo Maeda)" Date: 2022-09-23T10:28:47+00:00 Subject: [ruby-core:110043] [Ruby master Bug#18960] Module#using raises RuntimeError when called at toplevel from wrapped script Issue #18960 has been updated by shugo (Shugo Maeda). shioyama (Chris Salzberg) wrote in #note-14: > @shugo I've updated [my PR](https://github.com/ruby/ruby/pull/6226) and added a spec calling a method which calls `using`, which fails with the previous code but passes with the updated code. Can you have a look? Thank you! I found another corner case. The following code should be prohibited in a wrapped script: ``` MAIN = self module X MAIN.send(:using, Module.new) end ``` I suggested changes in the following comment: https://github.com/ruby/ruby/pull/6226#pullrequestreview-1118228759 ---------------------------------------- Bug #18960: Module#using raises RuntimeError when called at toplevel from wrapped script https://bugs.ruby-lang.org/issues/18960#change-99293 * Author: shioyama (Chris Salzberg) * Status: Open * Priority: Normal * ruby -v: 3.1.2p20 * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- I noticed that this file works when loaded with `load`, but fails if you pass `true` (or a module) as the `wrap` argument. ```ruby # using.rb using Module.new ``` This works: ```ruby load "./using.rb" ``` This doesn't: ```ruby load "./using.rb", true # raises RuntimeError (main.using is permitted only at toplevel) ``` I believe the latter should work. -- https://bugs.ruby-lang.org/ Unsubscribe: