From: "shioyama (Chris Salzberg)" Date: 2022-09-23T01:30:15+00:00 Subject: [ruby-core:110022] [Ruby master Bug#18960] Module#using raises RuntimeError when called at toplevel from wrapped script Issue #18960 has been updated by shioyama (Chris Salzberg). @shugo Actually, it seems the same problem _is_ there with `require`: ```ruby # foo.rb def foo using Module.new end foo ``` ```ruby require "foo" # main.using is permitted only at toplevel (RuntimeError) ``` So I don't really understand why Ruby allows the usage of `using` at toplevel with `require`, but not with `load`. Isn't this a problem in both cases? ---------------------------------------- Bug #18960: Module#using raises RuntimeError when called at toplevel from wrapped script https://bugs.ruby-lang.org/issues/18960#change-99273 * 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: