Skip to content

Conversation

@fglock
Copy link
Owner

@fglock fglock commented Oct 23, 2025

Root Cause:
Smart chunking creates closures at codegen time, when the package context in the symbol table may no longer match the source location. This caused function resolution to look in the wrong package, leading to "Undefined subroutine" errors for imported functions.

Solution:

  1. Track package changes through the AST during chunking
  2. Create symbol table snapshots with correct package context
  3. Store snapshots in SubroutineNode annotations
  4. Use pre-made snapshots in EmitSubroutine for chunked closures

This mimics how normal anonymous subroutines capture their parse-time context, ensuring imported functions are resolved correctly.

Smart chunking remains disabled by default pending full test suite validation. To re-enable, uncomment lines 66-69 in LargeBlockRefactorer.java.

Root Cause:
Smart chunking creates closures at codegen time, when the package
context in the symbol table may no longer match the source location.
This caused function resolution to look in the wrong package, leading
to "Undefined subroutine" errors for imported functions.

Solution:
1. Track package changes through the AST during chunking
2. Create symbol table snapshots with correct package context
3. Store snapshots in SubroutineNode annotations
4. Use pre-made snapshots in EmitSubroutine for chunked closures

This mimics how normal anonymous subroutines capture their parse-time
context, ensuring imported functions are resolved correctly.

Smart chunking remains disabled by default pending full test suite
validation. To re-enable, uncomment lines 66-69 in LargeBlockRefactorer.java.
@fglock fglock merged commit 0679798 into master Oct 23, 2025
2 checks passed
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.

2 participants