fix(semantic): stop following circular type declarations#1051
fix(semantic): stop following circular type declarations#1051CppCXY merged 1 commit intoEmmyLuaLs:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements cycle detection for Lua type aliases and class inheritance to prevent infinite recursion during type resolution. It introduces logic to collapse cyclic aliases to 'Any' and filters cyclic edges when retrieving super types. Review feedback identifies a potential performance bottleneck in the iterative cycle check, suggests exposing a helper function for broader use, and points out that the diagnostic checker currently misses cycles involving generic base classes.
add63a5 to
2b9e9d8
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces logic to detect and handle circular dependencies in Lua type aliases and class inheritance. It implements cycle detection in analyze_alias to collapse recursive aliases to LuaType::Any and filters cyclic super-type edges within the type index to prevent infinite recursion during type resolution. The review feedback correctly identifies potential logic errors in the new test cases, where assertions use negation (!) despite the test names and code structure suggesting that diagnostics for circularity should be reported.
2b9e9d8 to
86128b0
Compare
| Some(()) | ||
| } | ||
|
|
||
| fn alias_origin_reaches(db: &crate::DbIndex, origin: &LuaType, target_id: &LuaTypeDeclId) -> bool { |
When aliases or class parents point back to themselves, stop using that loop for normal analysis instead of trying to expand it forever. Pure alias loops now become any, and circular class parents are still visible to the existing diagnostic.
86128b0 to
c87ca5f
Compare
When aliases or class parents point back to themselves, stop using that
loop for normal analysis instead of trying to expand it forever.
Pure alias loops now become any, and circular class parents are still
visible to the existing diagnostic.