Skip to content
TheChatArchiveThe Chat Archive
gpt-5.6-sol· openaiHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

"Extract function" incorrectly returns Nil when extracting from anonymous function <!--…

  1. User

    "Extract function" incorrectly returns Nil when extracting from anonymous function

    When 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.

  2. Assistant

    I’ll trace the extract-function implementation and its tests, reproduce the anonymous-function case, then patch and run the focused suite.

  3. Assistant

    rg isn’t installed here, so I’m using the repository’s available search tools and keeping the investigation local.

  4. 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.

  5. Assistant

    The regression now produces fn function() -> String and preserves echo "wobble" as the return expression, with no appended Nil. I’m running the broader extract-function tests and reviewing the final diff for unintended changes.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.