ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "jeremyevans0 (Jeremy Evans)" <noreply@ruby-lang.org>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:109624] [Ruby master Bug#18960] Module#using raises RuntimeError when called at toplevel from wrapped script
Date: Mon, 22 Aug 2022 05:02:46 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-98809.20220822050245.13031@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-18960.20220809133842.13031@ruby-lang.org

Issue #18960 has been updated by jeremyevans0 (Jeremy Evans).


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?

I'm not sure whether this is a bug, but since `using` is permitted at top-;evel and also permitted in a module definition, it seems logical it should work at top-level with an implicit top-level module.  The pull request looks correct to me.  Not sure if the spec should use `ruby_bug`, I would just use `ruby_version_is`.

----------------------------------------
Bug #18960: Module#using raises RuntimeError when called at toplevel from wrapped script
https://bugs.ruby-lang.org/issues/18960#change-98809

* 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/

  parent reply	other threads:[~2022-08-22  5:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-09 13:38 [ruby-core:109456] [Ruby master Bug#18960] Module#using raises RuntimeError when called at toplevel from wrapped script shioyama (Chris Salzberg)
2022-08-09 13:44 ` [ruby-core:109457] " shioyama (Chris Salzberg)
2022-08-22  4:30 ` [ruby-core:109623] " shioyama (Chris Salzberg)
2022-08-22  5:02 ` jeremyevans0 (Jeremy Evans) [this message]
2022-08-22  6:19 ` [ruby-core:109625] " shugo (Shugo Maeda)
2022-08-22  7:48 ` [ruby-core:109626] " shioyama (Chris Salzberg)
2022-09-22 22:39 ` [ruby-core:110010] " mame (Yusuke Endoh)
2022-09-22 23:41 ` [ruby-core:110017] " shioyama (Chris Salzberg)
2022-09-22 23:55 ` [ruby-core:110019] " shugo (Shugo Maeda)
2022-09-23  1:25 ` [ruby-core:110021] " shioyama (Chris Salzberg)
2022-09-23  1:30 ` [ruby-core:110022] " shioyama (Chris Salzberg)
2022-09-23  1:36 ` [ruby-core:110023] " shioyama (Chris Salzberg)
2022-09-23  2:51 ` [ruby-core:110026] " shugo (Shugo Maeda)
2022-09-23  5:58 ` [ruby-core:110031] " shioyama (Chris Salzberg)
2022-09-23 10:28 ` [ruby-core:110043] " shugo (Shugo Maeda)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-98809.20220822050245.13031@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).