"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 inspect the extract-function implementation and its tests, reproduce the anonymous-function case, then patch and run the focused test suite.
- Assistant
The fault is in tail-position tracking: named functions and block expressions update the “last statement” marker, but anonymous function bodies do not. I’m adding the equivalent scoped tracking for function literals plus a regression test that verifies the extracted return type/body.
- Assistant
The focused result now has the intended semantics:
function() -> Stringwith no appendedNil. I’m accepting that regression snapshot, formatting the Rust changes, and running all extract-function tests to catch interactions with blocks, pipelines, and captured variables.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.