Closed jvilk-stripe closed 2 years ago
OK, here's what I believe is happening:
DRPC
symbol implicitly because it does not exist when Sorbet evaluates DRPC::SomeSubmodule
. Thus, DRPC
ends up having a loc in this file.module Foo::Bar
and Foo
exists, it does not add a loc to Foo
.DRPC
exists, so Sorbet does not update its loc when it encounters DRPC::SomeSubmodule
.I'll have to think on if a tractable solution is possible here.
I tried a different approach that assigns a none
Loc
to these classes, but that ends up propagating to the singleton classes we create and we don't update their loc when we process the actual definition (ugh).
Maybe I can force singletonClass
to update the singleton class loc or something.
This looks like the same issue as #1587 but I can't reproduce using this example either. Maybe we fixed it at one point.
Input
→ View on sorbet.run
Remove the comment to see the crash. Note: It does not occur in web builds.
Observed output
In debug build:
Expected behavior
No crash!
The issue occurs in a Sorbet error message that suggests an alternative constant since
Bundler::CRPC
does not exist. It suggests::DRPC
, which is defined at the end of the file.When you remove the comment, Sorbet fails to update the location information for
::DRPC
's definition, and tries to print a code location that does not exist.This problem does not occur if we simply define
module ::DRPC
instead ofmodule ::DRPC::SomeSubmodule
, which leads me to believe that there is a bug in incremental namer when entering a submodule on a module that has not yet been defined elsewhere.