"Extract function" incorrectly returns Nil when extracting from anonymous function <!--…
- User
"Extract function" incorrectly returns
Nilwhen extracting from anonymous functionWhen trying to extract a function from within an anonymous function, the extracted function always returns
Nil, even when incorrect.For example:
fn wibble() { let wobble = fn() { echo "wibble" echo "wobble" // extracting this line } }is turned into
fn wibble() { let wobble = fn() { echo "wibble" function() } } fn function() -> Nil { echo "wobble" Nil // this is incorrect! }I have a fix for it.
Interface
No new interfaces are introduced.
- Assistant
I'll search the codebase for the extract-function logic and how it handles return types inside anonymous functions.
- Assistant
Implementing the fix:
last_statement_locationwasn't updated for anonymous function bodies, so tail-position detection failed inside them. - Assistant
The fix works. Running the full extract-function test suite to check for regressions.
- Assistant
Implemented the fix for this bug. Here's what was going wrong and what changed.
Root cause
ExtractFunctiontrackslast_statement_locationto decide whether extracted code is in tail position (where the return type should be preserved) vs (where side-effect-only code gets an explicit return).
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.