0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Ruby】Steep が include した Math のメソッドを認識してくれない

0
Posted at

そろそろ RBS と Steep について勉強しておくか,と思っているが,最初からつまづきまくっている。

Math モジュールを include すると,レシーバー無しの sin とか sqrt とかが使える。

ところが Steep で検査すると「そんなメソッドは知らん」(意訳)と言われる。

再現手順

以下のスクリプトを用意。

lib/m.rb
module M
  include Math

  def foo(x)
    tan(x)
  end
end

とくに意味はない。

以下の RBS ファイルを用意。

sig/m.rbs
module M
  include Math

  def foo: (real) -> real
end

こんなふうに,モジュール M に何かを include していたら,RBS のほうでも同じように書けば認識してくれるはずだ。

ところが

steep check

すると

lib/m.rb:5:4: [error] Type `(::Object & ::M)` does not have method `tan`
│ Diagnostic ID: Ruby::NoMethod
│
└     tan(x)

と言われる。

Math は組込みクラスなのにな。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?