From: "shugo (Shugo Maeda)" Date: 2022-08-22T06:19:23+00:00 Subject: [ruby-core:109625] [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-3: > @jeremyevans0 You [most recently contributed to the `wrap` option](https://bugs.ruby-lang.org/issues/6210), what do you think about this? Am I correct to consider this a bug, and [this](https://github.com/ruby/ruby/pull/6226) the correct fix? main.using should not be called in a method definition even if it's a wrapped script. With your fix, the following script causes BUG: ``` excelsior:ruby$ cat using_in_method.rb # using.rb def foo using Module.new end foo excelsior:ruby$ cat t.rb load "./using_in_method.rb", true excelsior:ruby$ ./miniruby t.rb /Users/shugo/src/ruby/using_in_method.rb:3: [BUG] vm_cref_dup: unreachable ruby 3.2.0dev (2022-08-22T06:05:24Z shioyama-using_in_.. 08bdfcde78) [x86_64-darwin21] ``` I'm not sure whether this issue should be considered a bug, but it may be safe not to backport the fix to stable versions. ---------------------------------------- Bug #18960: Module#using raises RuntimeError when called at toplevel from wrapped script https://bugs.ruby-lang.org/issues/18960#change-98810 * 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: