Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda