Skip to content

Extracted function takes variables as parameters which are defined in the function #49

@mbeutelspacher

Description

@mbeutelspacher

For a similar example as in the demo

  std::vector foo = {1,2,3,4,5};
  // |
  for (size_t i = 0; i < foo.size(); ++i) {
      // \
      int bar = 3;
      std::cout << foo.at(i) + bar << std::endl;
      // \
   }
   // |

If the region marked with // | is selected and the function is extracted the following correct function is generated:

void baz(std::vector foo) {
  for (size_t i = 0; i < foo.size(); ++i) {
    int bar = 3;
    std::cout << foo.at(i) + bar << std::endl;
  }
}

However when I want to extract the inner function (marked with // \) I get

void baz(int bar, std::vector foo) {
  int bar = 3;
  std::cout << foo.at(i) + bar << std::endl;
}

which includes bar as a parameter although it is defined in the function body.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions