"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 trace the extract-function refactoring path, reproduce the anonymous-function case in the existing test suite, then patch and run the focused tests.
- Assistant
The failure is in tail-position tracking: blocks update the “last statement” marker, but anonymous-function bodies do not, so a selected final expression inherits the enclosing function’s position and is treated as non-tail. I’m adding a regression test around that exact distinction before changing the visitor.
- Assistant
The focused regression now produces
fn function() -> Stringand keepsecho "wobble"as the return expression—no appendedNil. I’m checking formatting and the broader language-server action tests for regressions.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →
- fable-5Compare side by side →