[#121215] [Ruby master Bug#21166] Fiber Scheduler is unable to be interrupted by `IO#close`. — "ioquatix (Samuel Williams) via ruby-core" <ruby-core@...>

Issue #21166 has been reported by ioquatix (Samuel Williams).

13 messages 2025/03/02

[#121222] [Ruby master Bug#21167] Visual Studio 2022 17.13.x couldn't build ruby.exe — "hsbt (Hiroshi SHIBATA) via ruby-core" <ruby-core@...>

Issue #21167 has been reported by hsbt (Hiroshi SHIBATA).

8 messages 2025/03/03

[#121234] [Ruby master Bug#21168] Prism doesn't require argument parentheses (in some cases) when a block is present but parse.y does — "Earlopain (Earlopain _) via ruby-core" <ruby-core@...>

Issue #21168 has been reported by Earlopain (Earlopain _).

8 messages 2025/03/04

[#121389] [Ruby Bug#21187] Strings concatenated with `\` getting frozen with literal hashes (PRISM only) — LocoDelAssembly via ruby-core <ruby-core@...>

Issue #21187 has been reported by LocoDelAssembly (Hern=E1n Pereira).

12 messages 2025/03/17

[#121413] [Ruby Bug#21193] Inherited callback returns `nil` for `Object.const_source_location` — "eileencodes (Eileen Uchitelle) via ruby-core" <ruby-core@...>

Issue #21193 has been reported by eileencodes (Eileen Uchitelle).

15 messages 2025/03/20

[#121451] [Ruby Bug#21201] Performance regression when defining methods inside `refine` blocks — "alpaca-tc (Hiroyuki Ishii) via ruby-core" <ruby-core@...>

Issue #21201 has been reported by alpaca-tc (Hiroyuki Ishii).

8 messages 2025/03/27

[ruby-core:121351] [Ruby master Misc#21143] Speficy order of execution const_added vs inherited

From: "fxn (Xavier Noria) via ruby-core" <ruby-core@...>
Date: 2025-03-13 15:40:51 UTC
List: ruby-core #121351
Issue #21143 has been updated by fxn (Xavier Noria).


The problem with `C = Class.new(parent)` is that it is a totally different mindset.

In the thing we are discussing, the interpreter is in charge.

In the other example, the user has decided to decouple both things. That anonymous class could be stored in a variable, passed three frames up and down, and perhaps be assigned to a constant 10 minutes later. Or never.

That is, in my mind instantiating an anonymous class object totally decouples the callbacks in a way that is expected.

Furthermore, if you have an autoload for `:C`:

```ruby
autoload :C, 'x'
```

`const_added` is going to be called before `inherited` anyway (because it is triggered by the `autoload` call itself). Analogous situation in my view, the user decided to decouple the actions.

----------------------------------------
Misc #21143: Speficy order of execution const_added vs inherited
https://bugs.ruby-lang.org/issues/21143#change-112323

* Author: fxn (Xavier Noria)
* Status: Feedback
----------------------------------------
The hooks `const_added` and `inherited` may need to be executed "together".

For example, consider:

```ruby
module M
  def self.const_added(cname) = ...

  class C
    def self.inherited(subclass) = ...
  end

  class D < C; end
end
```

When `D` is defined, two hooks are set to run, but in which order?

Both orders make sense in a way:

1. When `inherited` is called, you can observe that the subclass has a permanent name, ergo it was assigned to a constant, which must me stored in a class or module object. Therefore, the constant was added to said class/module before `inherited` was invoked.

1. When `const_added` is called, you can `const_get` the symbol and observe the object is a class, hence with a superclass, hence inheritance already happened.

The patch in [ruby#12759](https://github.com/ruby/ruby/pull/12759) documents and adds a test for (1). Rationale:

1. I believe it would be nice to specify this order.

1. Chose (1) because it is how it works today.

While the motivation for the patch was formal (to remove an ambiguity), after reflecting about this I realized users of Zeitwerk may depend on this. Nowadays, Zeitwerk uses `const_added` to set autoloads for child constants in namespaces. Thanks to the current order, code can be used in `inherited` hooks normally (it would not be ready if the order was different).




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/


In This Thread