Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda