jeremiah-c-leary / vhdl-style-guide

Style guide enforcement for VHDL
GNU General Public License v3.0
182 stars 38 forks source link

variable_011 touches Characters if a variable has the same name #1023

Closed masubious closed 7 months ago

masubious commented 10 months ago

Environment VSG Version: VHDL Style Guide (VSG) version: 3.17.0+zip.file Python: 3.10.7 (tags/v3.10.7:6cc6b13, Sep 5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)]

Describe the bug When formating with a default Config, Rule Variable_011 touches charactes with the same name as a variable. This may lead to invalid Code. In the attached example line " WHEN 'C'|'c' =>" will become " WHEN 'c'|'c' =>" and thus listing the choice for 'c' twice, because there is a second function which contains the variable c.

To Reproduce vsg -f var_pkg --fix

PACKAGE var_pkg IS

  FUNCTION to_slv (input : char) RETURN boolean;

  FUNCTION to_char (int : integer) RETURN character;

END PACKAGE var_pkg;

PACKAGE BODY var_pkg IS

  FUNCTION to_slv (input : char) RETURN boolean IS
  BEGIN
    CASE input IS
      WHEN 'C'|'c' =>
        RETURN true;

      WHEN OTHERS =>
        RETURN false;
    END CASE;

  END FUNCTION;

  FUNCTION to_char (int : integer) RETURN character IS

    VARIABLE c : character;

  BEGIN

    CASE int IS
      WHEN 0 =>
        c := '0';
      WHEN 1 =>
        c := '1';
      WHEN OTHERS =>
        c := '?';
    END CASE;

    RETURN c;

  END FUNCTION to_char;

END PACKAGE BODY var_pkg;

Expected behavior Don't touch Charactes that look like Code.

jeremiah-c-leary commented 9 months ago

Good Afternoon @masubious ,

I just pushed an update to this issue to the issue-551 branch. When you get a chance could you double check it on your end and let me know if the issue is resolved.

Just an FYI, there are three other issues associated with this issue: #551, #755, #998 and I will close this issue when all four issues are resolved.

Thanks,

--Jeremy

jeremiah-c-leary commented 9 months ago

Morning @masubious ,

Just wanted to ping you on this issue to see if you had time to check it out.

Thanks,

--Jeremy

masubious commented 9 months ago

@jeremiah-c-leary Hey, sorry for the delayed response. I quickly tested it with the supplied example and it seems to be fine :). Thanks for fixing!

jeremiah-c-leary commented 7 months ago

Afternoon @masubious ,

That is awesome. I will be merging this to master.

Regards,

--Jeremy