---
id: error-reference
title: Sorbet Error Reference
sidebar_label: Error Reference
---
> **Heads up**: There aren't any docs yet for
this error code. If you have suggestions for what would have helped you solve this problem, click the "Edit" button above to contribute! Otherwise, try using the search above to find an answer.
This is one of three docs aimed at helping answer common questions about Sorbet:
1. [Troubleshooting](troubleshooting.md)
1. [Frequently Asked Questions](faq.md)
1. [Sorbet Error Reference](error-reference.md) (this doc)
This page contains tips and tricks for common errors from Sorbet.
## 1001
Sorbet has crashed. Please [report an issue]!
## 1003
Sorbet has an internal limitation on how deep a chain of class aliases can be:
```ruby
A1 = Integer
A2 = A1
# ...
A42 = A41
A43 = A42 # error: Too many alias expansions
```
It's meant to guard against cases where Sorbet might get stuck in an infinite loop attempting to dealias these class aliases.
If you encounter this bug in the wild (i.e., not just for a contrived example, but a real-world use case), please share with the Sorbet team. We'd like to see what mode of use triggered this behavior, and either add a test to Sorbet or tweak how Sorbet works to support the use case.
## 1004
Sorbet couldn't find a file.
## 2001
There was a Ruby syntax error. Sorbet was unable to parse the source code. If you encounter this error but your code is accepted by Ruby itself, this is a bug in our parser; please [report an issue] to us so we can address it.
The only intentional break with the Ruby grammar is that method names that are keywords have some limitations with multi-line code, as explained in [Unsupported Ruby Features](unsupported.md#multi-line-calls-to-to-keyword-named-methods-with-trailing-).
## 2002
Starting in Ruby 3.0, Ruby uses the `_1`, `_2`, etc. syntax for block arguments:
```ruby
xs.map {_1.to_s}
# ^ this is equivalent to:
xs.map { |x| x.to_s }
```
Because of this, `_1` and similar variables are not allowed as normal variable names. Pick another variable name, for example: `_x1` or `_arg1`.
## 2003
If you're seeing this error code, it means that Sorbet already emitted a parse error for the file, but found some extra information that might help point out the root cause of a syntax error. For example:
```ruby
class A
def foo
if x
end
end
```
This Ruby snippet does not parse, but the reason why is confusing. Because Ruby does not care about indentation, it will try to consune `end` keywords eagerly if there is something available to match. In this example, the first `end` matches with `if` and the second matches with `def` and so Sorbet will report `unexpected token "end of file"` because the `class A` definition was not matched with an `end` token.
But given the indentation structure present in the original program, it's more likely that the `if x` statement is unclosed. Thus, in some cases, Sorbet will provide extra "Hint:" diagnostics that point out things that might be the root cause.
It's important to note that **these hints are imperfect**—fixing them might not actually fix the real parse error. Instead, they're provided as a way to help recover from the real parse error.
As with all Sorbet error messages, if one of these hint error messages is confusing or misleading, please [report an issue] to let us know.
## 2004
Starting in Ruby 3.0, Ruby uses the `_1`, `_2`, etc. syntax for block arguments:
```ruby
xs.map {_1.to_s}
# ^ this is equivalent to:
xs.map { |x| x.to_s }
```
Because of this, `_1` and similar variables are not allowed as normal variable names. Pick another variable name, for example: `_x1` or `_arg1`.
## 3001
Sorbet doesn’t support singleton definitions outside of the class itself:
```rb
class << MyClass # error: `class << EXPRESSION` is only supported for `class << self`
def foo
# ...
end
end
```
The workaround is to move the definition inside the `MyClass` class itself:
```rb
class MyClass
class << self
def foo
# ...
end
end
end
```
Sometimes, `EXPRESSION` is not a constant literal like in what follows:
```rb
class << some_variable
include Foo
end
```
In this case, it is possible to directly call `include` on the the singleton class of `EXPRESSION`, but it should be done with **utmost caution**, as Sorbet will not consider the include and provide a less accurate analysis (see also [#4002](#4002)):
```rb
some_variable.singleton_class.include(Foo)
```
## 3002
Sorbet is limited to C++ `INT_MAX`:
```rb
puts 11377327221391349843 + 1 # error: Unsupported integer literal: 11377327221391349843
```
A possible workaround is to use a string and `to_i`:
```rb
puts "11377327221391349843".to_i + 1
```
## 3003
Sorbet does not support certain Ruby features, like the flip flop operator and the `redo` keyword. If you feel strongly that Sorbet support these features, please open an issue.
Unfortunately, there is no workaround for this issue other than asking Sorbet to ignore the file (which forces the _entire_ file to be ignored, including any methods and constants defined in it), or rewriting the file to not use the unsupported Ruby feature.
If you do decide to ignore the file entirely, you will likely need to use an [RBI file](rbi.md) to let Sorbet know about any classes and methods defined in the ignored file.
## 3004
There was an error parsing a float literal in Sorbet. Specifically, we asked a C++ library to parse a Ruby float literal string to a float, and it returned a `NaN` value.
If you are seeing this error, it likely represents a bug in Sorbet. Please report an issue at