ruby/typeprof

[warning] already initialized constant Foo::A

ulcttku opened this issue · 1 comments

The warning [warning] already initialized constant Foo::A is displayed.
When a class with constants exists in an RBS file that has already been created.

Ruby TypeProf Playground
https://mame.github.io/typeprof-playground/#rb=class+Foo%0A++A+%3D+1%0Aend%0A&rbs=class+Foo%0A++A%3A+Integer%0Aend

Ruby

class Foo
  A = 1
end

RBS

class Foo
  A: Integer
end

Output

# TypeProf 0.15.0

# Errors
test.rb:2: [warning] already initialized constant Foo::A

# Classes
class Foo
  A: Integer
end


## Version info:
##   * Ruby: 3.0.0
##   * RBS: 1.3.1
##   * TypeProf: 0.15.0
mame commented

Thank you for your report and sorry for my late action! I've added a tentative fix to suppress the warning.

I'd like to keep this ticket open because there is still room to improve. If an inconsistent type is assigned to a constant that is already defined in RBS, currently it is merged but it should be warned. 4804e1e#diff-8ac76f2b46ac161391ac2190da7192f7c9b6263037c547efa93ecdfd47a6f660R2