Skip to content

AIGEN: Fix iterator compilation bug with value class field access (#769)#1077

Open
mbouaziz wants to merge 1 commit intomainfrom
fix-769-iterator-compilation-bug
Open

AIGEN: Fix iterator compilation bug with value class field access (#769)#1077
mbouaziz wants to merge 1 commit intomainfrom
fix-769-iterator-compilation-bug

Conversation

@mbouaziz
Copy link
Contributor

@mbouaziz mbouaziz commented Feb 6, 2026

Summary

  • Fixed issue Iterator compilation bug: reached an Unreachable point #769 where the compiler incorrectly marked code as unreachable when accessing fields of value classes (like Some<T>.value) if the field type appeared as unresolved type _ during compilation
  • The bug occurred with lazy iterator chains using flatMap and filter with yield
  • Moved the canInstantiate check inside the NamedLeaf branch only (for reference classes which require scalarization), allowing value class field access to proceed without this check
  • Removed the .collect(Array) workaround in SqlSchemaMigration.sk

Test plan

  • All 1698 compiler tests pass
  • SQL library compiles successfully without .collect(Array) workaround
  • The generic_refinement_method test continues to pass (regression test for the fix)

Fixes #769

🤖 Generated with Claude Code

The compiler was incorrectly marking code as unreachable when accessing
fields of value classes (like Some<T>.value) if the field type appeared
as unresolved type `_` during compilation. This happened with lazy
iterator chains using flatMap and filter with yield.

The fix moves the canInstantiate check inside the NamedLeaf branch only
(for reference classes which require scalarization), allowing value class
field access to proceed without this check since it's just bookkeeping.

This removes the .collect(Array) workaround in SqlSchemaMigration.sk.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mbouaziz
Copy link
Contributor Author

mbouaziz commented Feb 6, 2026

This PR was created using no other guidance than "Fix #769"

@mbouaziz mbouaziz requested review from jberdine and pikatchu February 6, 2026 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Iterator compilation bug: reached an Unreachable point

1 participant