Closed mame closed 5 years ago
require "rdl" module Foo extend RDL::Annotate module Bar end type "() -> %any", typecheck: :now def refer_bar Bar end end
$ ruby t.rb Traceback (most recent call last): 10: from t.rb:3:in `<main>' *snip* 1: from /home/mame/local/lib/ruby/gems/2.5.0/gems/rdl-2.1.0/lib/rdl/typecheck.rb:636:in `tc' /home/mame/local/lib/ruby/gems/2.5.0/gems/rdl-2.1.0/lib/rdl/typecheck.rb:636:in `const_get': uninitialized constant RDL::Typecheck::Bar (NameError)
This error occurs even if I replace Bar with Foo::Bar in refer_bar.
Bar
Foo::Bar
refer_bar
The following patch fixes this issue, but I'm unsure if this is a right way.
diff --git a/lib/rdl/typecheck.rb b/lib/rdl/typecheck.rb index a1962ce..390fb77 100644 --- a/lib/rdl/typecheck.rb +++ b/lib/rdl/typecheck.rb @@ -630,11 +630,8 @@ module RDL::Typecheck raise "const other not implemented yet" end case c - when TrueClass, FalseClass, Complex, Rational, Integer, Float, Symbol, Class + when TrueClass, FalseClass, Complex, Rational, Integer, Float, Symbol, Class, Module [env, RDL::Type::SingletonType.new(c)] - when Module - t = RDL::Type::SingletonType.new(const_get(e.children[1])) - [env, t] else [env, RDL::Type::NominalType.new(const_get(e.children[1]).class)] end
I've hit this as well, and the proposed fix worked for me. :+1:
This is fixed in dev, and will be merged with master shortly.
This error occurs even if I replace
Bar
withFoo::Bar
inrefer_bar
.The following patch fixes this issue, but I'm unsure if this is a right way.