rbs
rbs copied to clipboard
UnknownMethodAliasError in alias method on included module
Following code raise RBS::UnknownMethodAliasError.
require 'rbs'
loader = RBS::EnvironmentLoader.new
env = RBS::Environment.from_loader(loader)
rbs = <<~DEF
module Mod
alias request send
end
class Foo
include Mod
end
DEF
RBS::Parser.parse_signature(rbs).each do |decl|
env << decl
end
definition_builder = RBS::DefinitionBuilder.new(env: env.resolve_type_names)
definition_builder.build_instance(TypeName("::Foo"))
/Users/ksss/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rbs-2.5.0/lib/rbs/definition_builder.rb:577:in `block in define_methods': a.rbs:2:2...2:20: Unknown method al
ias name: send => request (::Mod) (RBS::UnknownMethodAliasError)
I expect to define alias from Object#send to Mod#request.
However, when I examine the rbs code, I find that the definiton prevents the self_type method of the included module from being read. This code seems to solve https://github.com/ruby/rbs/pull/577 .
Is it intended that the code in question is RBS::UnknownMethodAliasError?
rbs: v2.5.0 ruby: v3.1.1
@ksss Thank you for reporting the problem. This is a bug. I will take a look at this. 🙇♂️