diary

I like Hatena Star with a text selection.

2020-07-12 - RBS周りで色々。

github.com

RBS::Environment#inspectが長すぎてつらいことが何度かあったので、短くしてみた。


RBSでは定数の名前解決のときに、継承関係を考慮しない。

Note that the type name resolution does not refer inheritance and includes.

https://github.com/ruby/rbs/pull/307

つまり次のようになる。

class C
  module M
  end
end

class C2 < C
  # Could not find mixin: M
  include M
end

class C3
  # Could not find mixin: C2::M
  include C2::M
end

これは、Active Supportの型を出す時に::Logger::Severityincludeするのに、::Loggerを継承した::ActiveSupport::Logger::Severityをincludeしようとしていてハマった。


github.com

rbs_railsRBSの新構文に対応させた。

とりあえずActive Supportだけ対応して、Active Modelの型はさよならした。 rbs prototype rbの機能不足を感じたので、なんとかする。


github.com

Active Supportの型を生成している時に、Rubyのバージョンごとに違う中身でメソッドを定義しているようなコードで型が2重に出て面倒だったので、rbs prototype rbの方を直した。