Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[warning] already initialized constant Foo::A #59

Open
ulcttku opened this issue Oct 9, 2021 · 1 comment
Open

[warning] already initialized constant Foo::A #59

ulcttku opened this issue Oct 9, 2021 · 1 comment

Comments

@ulcttku
Copy link

ulcttku commented Oct 9, 2021

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 mame closed this as completed in f7a1584 Oct 25, 2021
@mame mame reopened this Oct 25, 2021
mame added a commit that referenced this issue Oct 25, 2021
@mame
Copy link
Member

mame commented Oct 25, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants