Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
Can invalid signature errors ever trigger at runtime if code has been statically checked by Sorbet?

I was looking through the list of Sorbet runtime errors from the docs. It seems to me that "Errors from invalid sig procs" and "Errors from invalid sigs" would be caught by the Sorbet type checker. If your code passes Sorbet's static checks, is it guaranteed that those runtime errors would never occur?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Basic answer

There are cases in which the static checks pass, but you'd get a runtime error. Consider the following:

# typed: strict

class A
  extend T::Sig
  sig {returns(Integer)}
  def foo; 0; end
end

class B < A
  sig {returns(String)}
  def foo; '0'; end
end

B.new.foo

Running this will end up in:

RuntimeError: Incompatible return type in signature for override of method `foo`

Extra

You can avoid falling in this by making sure that you use overridable or (:final) (docs) in your signatures when appropriate.

class A
  extend T::Sig
  sig {overridable.returns(Integer)}
  def foo; 0; end

  sig (:final) {returns(Integer)}
  def bar; 0; end
end

class B < A
  sig {returns(String)} # this will fail static check, as it doesn't declare `override`
  def foo; '0'; end

  sig {returns(String)} # this will fail static check, as `bar` is `final`
  def bar; '0'; end
end
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!