aaronc81 / pry-sorbet Goto Github PK
View Code? Open in Web Editor NEWPry extension for Sorbet
License: MIT License
Pry extension for Sorbet
License: MIT License
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
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!
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.