Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-27775

"Extract subexpression to variable" reuses variable name

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P2: Important
    • None
    • Qt Creator 8.0.0-rc1
    • C/C++/Obj-C++ Support
    • Ubuntu 20.04 LTS
      Windows 10 21H2

    Description

      1. Have a trivial line in a source file:
            int i = 1 + 2 + 3 + 4;
        
      2. Select the first half of the sum, e.g. the first two summands and the plus sign.
      3. Press Alt+Enter and select "clang: Extract subexpression to variable" from the popup menu.
        Works as expected:
            auto placeholder = 1 + 2;
            int i = placeholder + 3 + 4;
        
      4. Select the second half of the sum, e.g. the last two summands and their plus sign.
      5. Press Alt+Enter and select "clang: Extract subexpression to variable" from the popup menu.
        This reuses the same variable name creating a compile error:
            auto placeholder = 1 + 2;
            auto placeholder = 3 + 4;
            int i = placeholder + placeholder;
        

      This should use distinct variable names.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kandeler Christian Kandeler
            rlohning Robert Löhning
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes