From: "shugo (Shugo Maeda)" Date: 2022-09-23T02:51:49+00:00 Subject: [ruby-core:110026] [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-12: > Oh never mind, I see. My PR results in the error with `require` but the `unreachable` BUG with `load`. > > Ok I'll try to find another way to fix it. Yes, RuntimeError should be raised in both cases. ---------------------------------------- Bug #18960: Module#using raises RuntimeError when called at toplevel from wrapped script https://bugs.ruby-lang.org/issues/18960#change-99277 * 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: