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

Rail's JSON support causes issues #76

Closed
wagenet opened this issue Dec 9, 2021 · 2 comments · Fixed by #77
Closed

Rail's JSON support causes issues #76

wagenet opened this issue Dec 9, 2021 · 2 comments · Fixed by #77

Comments

@wagenet
Copy link
Contributor

wagenet commented Dec 9, 2021

This can also be produced with the following file:

require "json"

class Exception
  def as_json(options = nil)
    to_s
  end
end

This causes the following backtrace

/Users/peterwagenet/Development/Ruby/typeprof/lib/typeprof/utils.rb:4:in `array_update': undefined method `%' for nil:NilClass (NoMethodError)
        from /Users/peterwagenet/Development/Ruby/typeprof/lib/typeprof/analyzer.rb:234:in `local_update'
        from /Users/peterwagenet/Development/Ruby/typeprof/lib/typeprof/method.rb:117:in `do_check_send'
        from /Users/peterwagenet/Development/Ruby/typeprof/lib/typeprof/method.rb:307:in `block in do_match_iseq_mdef'
        from /Users/peterwagenet/Development/Ruby/typeprof/lib/typeprof/method.rb:306:in `each'
        from /Users/peterwagenet/Development/Ruby/typeprof/lib/typeprof/method.rb:306:in `do_match_iseq_mdef'
        from /Users/peterwagenet/Development/Ruby/typeprof/lib/typeprof/analyzer.rb:2421:in `block in do_define_iseq_method'
        from /Users/peterwagenet/Development/Ruby/typeprof/lib/typeprof/analyzer.rb:2420:in `each'
        from /Users/peterwagenet/Development/Ruby/typeprof/lib/typeprof/analyzer.rb:2420:in `do_define_iseq_method'
        from /Users/peterwagenet/Development/Ruby/typeprof/lib/typeprof/analyzer.rb:1413:in `step'
        from /Users/peterwagenet/Development/Ruby/typeprof/lib/typeprof/analyzer.rb:1050:in `type_profile'
        from /Users/peterwagenet/Development/Ruby/typeprof/lib/typeprof/config.rb:123:in `analyze'
        from exe/typeprof:9:in `<main>'
@wagenet
Copy link
Contributor Author

wagenet commented Dec 9, 2021

So far my best guess is that this happens because this changes the type from what is defined previously via rbs.

@wagenet
Copy link
Contributor Author

wagenet commented Dec 9, 2021

Actually, I believe it's due to the arguments type changing. Another interesting thing to note is that the new return type is ignored.

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

Successfully merging a pull request may close this issue.

1 participant