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

Codegen'd Ruby with generate_types: true doesn't extend T::Sig #169

Open
2 tasks
davebenvenuti opened this issue Jan 14, 2025 · 0 comments
Open
2 tasks
Assignees
Labels
Bug Something isn't working

Comments

@davebenvenuti
Copy link
Contributor

evaling generated Ruby with generate_types: true results in an undefined method error:

https://github.com/Shopify/protoboeuf/blob/f537118067e6f2b1472fb9beb206d110d1ecc96a/test/fixtures/typed_test.correct.rb

irb(main):002* Module.new do
irb(main):003*   class_eval File.read("test/fixtures/typed_test.correct.rb")
irb(main):004> end
(eval at (irb):3):11:in `<module:TestEnum>': undefined method `sig' for module #<Module:0x000000011de4afc0>::TestEnum (NoMethodError)

  sig { params(val: Integer).returns(Symbol) }
  ^^^
        from (eval at (irb):3):6:in `block in <top (required)>'
        from (irb):3:in `class_eval'
        from (irb):3:in `block in <top (required)>'
        from (irb):2:in `initialize'
        from (irb):2:in `new'
        from (irb):2:in `<main>'
        from <internal:kernel>:187:in `loop'
        from /Users/dave/.gem/ruby/3.3.4/gems/irb-1.14.3/exe/irb:9:in `<top (required)>'
        from /Users/dave/.gem/ruby/3.3.4/bin/irb:25:in `load'
        from /Users/dave/.gem/ruby/3.3.4/bin/irb:25:in `<main>'
irb(main):005>

I understand in some environments people extend T::Sig in Object so this is unnecessary, but we can't guarantee that to be the case. This evaled code should work in a vanilla Ruby environment.

Tasks

Preview Give feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant