Skip to content

Comments

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

Open
mbouaziz wants to merge 2 commits intomainfrom
fix-769-iterator-compilation-bug
Open

AIGEN: Fix iterator compilation bug with value class field access (#769)#1077
mbouaziz wants to merge 2 commits 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

Verification

Verified end-to-end by building Docker images with STAGE=1 (stage1 compiler compiled from source, which includes this fix) and running the full skdb test suite:

# Build with the fixed compiler
STAGE=1 bin/docker_build.sh --arch amd64 skiplang skip skdb-base

# Clean stale build artifacts (static_state.db format mismatch between compiler versions)
docker run --rm -v $PWD:/work skiplabs/skdb-base:latest \
  bash -c "find /work -name static_state.db -delete"

# Run tests
docker run --rm --network=host -v $PWD:/work -w /work \
  skiplabs/skdb-base:latest bash -c "make test-native"
docker run --rm --network=host -v $PWD:/work -w /work \
  skiplabs/skdb-base:latest bash -c "make test-wasm"

Test plan

  • All 1698 compiler tests pass
  • skdb native tests: 1265 tests pass (including ALTER TABLE ADD COLUMN which exercises schema migration with the lazy iterator code path)
  • skdb wasm tests: 283/283 pass
  • The generic_refinement_method test continues to pass (regression test for the fix)
  • Verified locally by reviewer

Fixes #769

🤖 Generated with Claude Code

@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
@mbouaziz mbouaziz force-pushed the fix-769-iterator-compilation-bug branch from 56c71a9 to 77317fa Compare February 9, 2026 13:32
@jberdine
Copy link
Contributor

jberdine commented Feb 9, 2026

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

Did you review it?

@mbouaziz
Copy link
Contributor Author

mbouaziz commented Feb 9, 2026

I did review but I didn't take time to collect enough context to understand it deeply.
Anyways, CI is still red so Claude is still clauding...
turning the PR to draft

@mbouaziz mbouaziz marked this pull request as draft February 9, 2026 16:08
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 mbouaziz force-pushed the fix-769-iterator-compilation-bug branch from 77317fa to 3acdd84 Compare February 20, 2026 11:51
- Update bootstrap submodule to include the compiler fix
- Point all CI images to the fix-769 tag built with the new bootstrap

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

CI setup for this PR

This PR includes a temporary second commit that:

  1. Updates the bootstrap submodule — regenerated from stage1 with the specialize.sk fix (make -C skiplang/compiler promote using the fixed compiler)
  2. Points CI images to fix-769 tag — Docker images (skiplabs/skiplang:fix-769, skiplabs/skip:fix-769, skiplabs/skdb-base:fix-769) were built locally with the new bootstrap and pushed to Docker Hub (amd64 only)

This allows CI to run the full test suite using a compiler that includes the fix, verifying end-to-end correctness.

Before merging, the second commit (ci: use fix-769 Docker images and updated bootstrap) should be squashed/dropped and the bootstrap submodule updated separately through the normal process.

Local verification results

  • Native tests: 1265 pass (including ALTER TABLE ADD COLUMN which exercises the fixed code path)
  • Wasm tests: 283/283 pass
  • Compiler tests: 1698 pass

@mbouaziz mbouaziz marked this pull request as ready for review February 20, 2026 13:37
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

2 participants