2021/10/21 今回の気になった bugs.ruby のチケット

今週は YJIT が Ruby 本体に取り込まれました。

[Feature #6210] load should provide a way to specify the top-level module

  • load メソッドに Module を指定できるようにする提案
  • 以下のように特定のモジュールに対して load した Ruby のコードが展開される
# test.rb
def hoge
  "hoge"
end

class Foo
  def foo
    "foo"
  end
end
module M
end

# M に対して test.rb の中身が定義される
load "./test.rb", M

p M::Foo
# => M::Foo

p M::Foo.new.foo
# => "foo"

class X
  include M
  public :hoge
end

p X.new.hoge
# => "hoge"
  • チケット自体はだいぶ古いものだけど最近実装した PR ができてた
  • なにかいろいろと利用できそうな気がするんですが具体的にどういう場面で利用できそうかな…

[Bug #17719] Irregular evaluation order in hash literals

  • Hash リテラルで同名のキーが存在する場合に評価順が左からにならないバグ報告
  • 最近修正された
ary = []
{ a: ary << 1, b: ary << 2, a: ary << 3 }
pp ary
# Ruby 3.0 => [1, 3, 2]
# Ruby 3.1 => [1, 2, 3]

[Feature #18229] Proposal to merge YJIT

  • マージされました!!!
  • --yjit オプションを付けて実行できるよ!!!