-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Propagate locations correctly for enums (#213)
The old code triggered an ENFORCE when encountering enums; this patch fixes that issue. However, the handling is not quite right, as we're not emitting a definition correctly. We do emit an extra class def/ref, however, the class is not referenced elsewhere, the constant is. Follow-up issue for improving that:
- Loading branch information
1 parent
9058a6a
commit 527916d
Showing
4 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# typed: struct | ||
|
||
class X < T::Enum | ||
enums do | ||
A = new("A") | ||
B = new | ||
end | ||
|
||
All = T.let([A, B], T::Array[X]) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# typed: struct | ||
|
||
class X < T::Enum | ||
# ^ reference [..] X# | ||
# ^ definition [..] X# | ||
# ^ definition [..] X#serialize(). | ||
# ^ reference [..] T# | ||
# ^^^^ reference [..] Module#public(). | ||
# ^^^^ reference [..] String# | ||
# ^^^^ reference [..] T#Enum# | ||
enums do | ||
A = new("A") | ||
# ^ definition local 2~#119448696 | ||
# ^ definition [..] X#A# | ||
# ^ reference [..] X#A# | ||
# ^ reference [..] X#A. | ||
# ^^^ reference [..] Class#new(). | ||
B = new | ||
# ^ definition local 5~#119448696 | ||
# ^ definition [..] X#B# | ||
# ^ reference [..] X#B# | ||
# ^ reference [..] X#B. | ||
# ^^^ reference [..] Class#new(). | ||
end | ||
|
||
All = T.let([A, B], T::Array[X]) | ||
# ^^^ definition [..] X#All. | ||
# ^ reference [..] X#A. | ||
# ^ reference [..] X#B. | ||
# ^^^^^^^^ definition local 8~#119448696 | ||
# ^ reference [..] X# | ||
end |