Skip to content

Remap borrowed inline iterator symbols in sema, restore strict codegen, and add distinct/borrow runtime tests#15

Merged
Clemente90 merged 1 commit intodevelfrom
codex/add-tests-for-borrow-pragma-in-distinct-types
Jan 21, 2026
Merged

Remap borrowed inline iterator symbols in sema, restore strict codegen, and add distinct/borrow runtime tests#15
Clemente90 merged 1 commit intodevelfrom
codex/add-tests-for-borrow-pragma-in-distinct-types

Conversation

@Clemente90
Copy link
Owner

Motivation

  • Ensure borrowed inline iterator bodies reference the borrowing iterator's symbols to avoid semantic mismatches and internal codegen errors when borrowing inline iterators.
  • Keep runtime coverage for distinct/borrow behaviors (iterators, arrays, seq, Table, nested distinct conversions and borrowed methods) to prevent regressions.
  • Restore stricter codegen/statement-location checks to avoid spurious internal errors during compilation of inline iterators.

Description

  • Add replaceOwnedSyms and update semBorrow in compiler/semstmts.nim so that when an inline iterator is borrowed its body is copied and any symbols owned by the borrowed iterator are remapped to the borrowing iterator.
  • Add runtime tests exercising borrowed iterators and nested distinct conversions in tests/distinct/ (tborrow_iterators.nim, tborrow_subclass_methods.nim, tdistinct_language_string.nim, tdistinct_nested.nim).
  • Remove previously added relaxations in codegen/statement emission so the compiler keeps the original stricter checks (prevents "proc has no result symbol" and related internal errors for inline iterators).

Testing

  • Ran bin/testament --print --nim:./bin/nim p tests/distinct and all tests in tests/distinct passed (43/43).
  • Built and ran the iterator-specific test with ./koch temp c --hints:off tests/distinct/tborrow_iterators.nim and it completed successfully.
  • Ran the bootstrap build ./koch boot -d:release --skipUserCfg --skipParentCfg --hints:off and it succeeded without error.

Codex Task

@Clemente90 Clemente90 merged commit 4bd76cc into devel Jan 21, 2026
@Clemente90 Clemente90 deleted the codex/add-tests-for-borrow-pragma-in-distinct-types branch January 21, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant