"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 implementation and its tests, reproduce the anonymous-function case, then patch and run the focused suite.
- Assistant
rgisn’t installed here, so I’m using the repository’s available search tools and keeping the investigation local. - Assistant
The fault is in tail-position tracking: named functions and explicit blocks set their final statement, but anonymous-function bodies do not. I’m adding the same scoped tracking for function literals plus a regression snapshot for the reported selection.
- Assistant
The regression now produces
fn function() -> Stringand preservesecho "wobble"as the return expression, with no appendedNil. I’m running the broader extract-function tests and reviewing the final diff for unintended changes.
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 →