Skip to content

Commit

Permalink
Fix "unknown type var: Elem"
Browse files Browse the repository at this point in the history
Adding a method to Array caused the error
  • Loading branch information
mame committed Aug 8, 2024
1 parent af1c7a4 commit 0c3d71d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/typeprof/core/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,10 @@ def initialize(cpath, scope_level, mid, outer)
def get_self(genv)
case @scope_level
when :instance
Source.new(Type::Instance.new(genv, genv.resolve_cpath(@cpath || []), []))
mod = genv.resolve_cpath(@cpath || [])
type_params = mod.type_params.map {|ty_param| Source.new() } # TODO: better support
ty = Type::Instance.new(genv, mod, type_params)
Source.new(ty)
when :class
Source.new(Type::Singleton.new(genv, genv.resolve_cpath(@cpath || [])))
else
Expand Down
11 changes: 11 additions & 0 deletions scenario/misc/array-as-self.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## update
class Array
def quote
each {|s| s.quote }
end
end

## assert
class Array
def quote: -> Array[untyped]
end

0 comments on commit 0c3d71d

Please sign in to comment.