mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-17 21:12:42 +00:00
fixes #25697 This pull request improves the handling of borrowed routines in the compiler transformation phase, making the code more robust and maintainable. The main change is the introduction of a helper function to properly resolve borrowed routine symbols, which is then used in multiple places to ensure correct symbol resolution. Additionally, a new test case is added to cover a previously reported bug related to borrowed iterators on distinct types. **Compiler improvements:** * Added `resolveBorrowedRoutineSym` helper function to follow borrow aliases and retrieve the underlying implementation symbol for borrowed routines. This centralizes and clarifies the logic for resolving borrowed symbols. * Updated `transformSymAux` and `transformFor` to use the new helper function, replacing duplicated logic and improving correctness when handling borrowed routines. [[1]](diffhunk://#diff-c7b80f51fb685eb22c5b56ee2f320d6c708706f3ae7293478ecd104a2b5b8096L139-R154) [[2]](diffhunk://#diff-c7b80f51fb685eb22c5b56ee2f320d6c708706f3ae7293478ecd104a2b5b8096L788-R795) **Testing:** * Added a test case for bug #25697 to `tests/distinct/tborrow.nim`, ensuring that iteration over a distinct type with a borrowed iterator works as expected.