Git Product home page Git Product logo

pry-sorbet's Issues

sorbet-unwrap: abstracts methods may mask implementing methods

sorbet-unwrap also unwraps abstract methods.
This is a problem, because normal Ruby code wouldn't have abstract methods at all.
Usually Sorbet hides abstracts methods, so Ruby ignores this concept which it doesn't know.

@paracycle (see also #2 )
Do you have an Idea how to ignore methods with mode == T::Private::Methods::Modes.abstract when unwrapping?

Background: sorbet/sorbet#1969
There I tried another way to enable stepping though methods with signatures. And I ran into the same problem.

Here you can see the actual problem caused by this.
If the abstract method isn't hidden by Sorbet, it will overwrite the implementing method and change the behavior of the problem.
→ View on sorbet.run

module FancyModule
  extend T::Sig
  extend T::Helpers
  abstract!

  #sig { abstract.returns(Integer) }
  def foo; end

  def inspected_foo
    foo.inspect
  end
end

class Parent
  def foo
    42
  end
end

class Child < Parent
  include FancyModule
  def initialize
    puts(inspected_foo)
  end
end

if ENV['SORBET_UNWRAP']
  require 'pry-sorbet'
  Pry.run_command 'sorbet-unwrap'
end

Child.new
# ruby THIS_SCRIPT => 42
# SORBET_UNWRAP=true ruby THIS_SCRIPT => nil

Recommendations for use with debug gem

Hello!

I'm starting to use the new ruby debugger (https://github.com/ruby/debug) in VSCode and making use of this gem to skip through sorbet stuff. Right now, I'm just manually calling PrySorbet::UnwrapCommand.new.process in my debugger, and it works like a charm. Is there a recommended way to automatically run this when entering a debug session with debug? This is called pry-sorbet so maybe supporting debug is a non-goal, but I thought I'd ask!

sorbet-unwrap: debugging inside T.let / T.cast still a problem

Sadly sorbet-unwrap won't help if there's a method call inside T.let(..., or T.cast(..., .

 

Proposal: sorbet-unwrap could overwrite T.let / T.cast with a minimal implementation, which simply forwards the first argument and ignores the second.

module T
  def self.let(value, type, checked: true)
    value
  end
  
  def self.cast(value, type, checked: true)
    value
  end
end

 

Sadly I've no idea how the evaluation of the second parameter may be skipped. This would be a problem, if the second parameter is something like T::Array[Integer] because there will be code to step trough.

See also: sorbet/sorbet#3279

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.