|
1 | 1 | // NOTE: Protobuf headers should go first since they use poisoned functions.
|
2 | 2 | #include "proto/SCIP.pb.h"
|
3 | 3 |
|
| 4 | +#include <algorithm> |
4 | 5 | #include <fstream>
|
5 | 6 | #include <iterator>
|
6 | 7 | #include <memory>
|
@@ -977,14 +978,25 @@ class CFGTraversal final {
|
977 | 978 | todo.emplace_back(namedSym, loc);
|
978 | 979 | }
|
979 | 980 | }
|
| 981 | + bool foundDupes = false; |
980 | 982 | // Sort for determinism
|
981 | 983 | fast_sort(todo, [&](const SymbolWithLoc &p1, const SymbolWithLoc &p2) -> bool {
|
982 |
| - ENFORCE(p1.second.beginPos() != p2.second.beginPos(), |
983 |
| - "found alias instructions with same start offset in {}, source:\n{}\nsym1 = {}, sym2 = {}\n", |
984 |
| - file.data(gs).path(), core::Loc(file, p1.second).toString(gs), p1.first.showRaw(gs), |
985 |
| - p2.first.showRaw(gs)); |
| 984 | + if (p1.second.beginPos() == p2.second.beginPos()) { |
| 985 | + // TODO: This code path is hit when there is a module_function on top of a sig. |
| 986 | + // In that case, the 'T' and 'X' in 'T::X' in a sig end up with two occurrences each. |
| 987 | + // We should check if this is a Sorbet bug or deliberate. |
| 988 | + ENFORCE(p1.first == p2.first, |
| 989 | + "found different symbols at same location in {}, source:\n{}\nsym1 = {}\nsym2 = {}\n", |
| 990 | + file.data(gs).path(), core::Loc(file, p1.second).toString(gs), p1.first.showRaw(gs), |
| 991 | + p2.first.showRaw(gs)); |
| 992 | + foundDupes = true; |
| 993 | + } |
986 | 994 | return p1.second.beginPos() < p2.second.beginPos();
|
987 | 995 | });
|
| 996 | + if (foundDupes) { |
| 997 | + auto last = unique(todo.begin(), todo.end()); |
| 998 | + todo.erase(last, todo.end()); |
| 999 | + } |
988 | 1000 | // NOTE:(varun) Not 100% sure if emitting a reference here. Here's why it's written this
|
989 | 1001 | // way right now. This code path is hit in two different kinds of situations:
|
990 | 1002 | // - You have a reference to a nested class etc. inside a method body.
|
|
0 commit comments