Skip to content

Commit

Permalink
Do not warn "already initialize constant" if it is defined in RBS
Browse files Browse the repository at this point in the history
Fixes #59
  • Loading branch information
mame committed Oct 25, 2021
1 parent 988563c commit f7a1584
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/typeprof/analyzer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1933,8 +1933,13 @@ def step(ep)
when :setconstant
name, = operands
env, (ty, cbase) = env.pop(2)
old_ty, = get_constant(cbase, name)
if old_ty != Type.any # XXX???
old_ty, old_locs = get_constant(cbase, name)
if old_locs == [nil] # RBS defined
# TODO: it would be better to check if ty is consistent with old_ty (defined in RBS)
# instead of extending the type
env, old_ty = localize_type(globalize_type(old_ty, env, ep), env, ep)
ty = ty.union(old_ty)
elsif old_ty != Type.any # XXX???
warn(ep, "already initialized constant #{ Type::Instance.new(cbase).screen_name(self) }::#{ name }")
end
ty.each_child do |ty|
Expand Down

0 comments on commit f7a1584

Please sign in to comment.