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 refactoring path, reproduce the anonymous-function case in the existing test suite, then patch and run the focused tests.

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

  4. Assistant

    The focused regression now produces fn function() -> String and keeps echo "wobble" as the return expression—no appended Nil. I’m checking formatting and the broader language-server action tests for regressions.

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