jeremiah-c-leary / vhdl-style-guide

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

`architecture_029` aligns declarations within protected type declarative regions with declarations outside #1287

Open JHertz5 opened 1 week ago

JHertz5 commented 1 week ago

Environment VSG v3.27.0

Describe the bug The rule architecture_029 modifies the alignment of declarations within the declarative region of protected types as if they are a normal part of the architecture's declarative region. It's likely that other declarative regions in which protected types may be declared will suffer from similar problems.

To Reproduce Steps to reproduce the behavior:

  1. Create test file

    
    architecture rtl of test is
    
    type flag_pt is protected
    
    procedure set;
    
    procedure clear;
    
    impure function get return boolean;
    end protected;
    
    type       flag_pt is protected body
    variable flag : boolean;
    end protected body;

begin

end architecture rtl;

2. Run `vsg -f test.vhd --fix`
3. See error
```vhdl
architecture rtl of test is

  type flag_pt is protected

    procedure set;

    procedure clear;

    impure function get return boolean;
  end protected;
  --  vvvvvvv
  type       flag_pt is protected body
    variable flag : boolean;
  end protected body;

begin

end architecture rtl;

Expected behavior

architecture rtl of test is

  type flag_pt is protected

    procedure set;

    procedure clear;

    impure function get return boolean;
  end protected;

  type flag_pt is protected body
    variable flag : boolean;
  end protected body;

begin

end architecture rtl;
JHertz5 commented 1 week ago

Similar problems discovered with package_body_400, package_body_401, and architecture_026.

Expected output

package test is

  type flag_pt is protected

    procedure set;

    procedure clear;

    impure function get return boolean;
  end protected;

end package test;

package body test is

  constant c_my_const : boolean := false;
  type flag_pt is protected body
    variable flag  : boolean;
    variable flags : boolean;
    constant test  : integer := 1;
  end protected body;

end package body test;

architecture rtl of test is

  type flag_pt is protected

    procedure set;

    procedure clear;

    impure function get return boolean;
  end protected;

  constant c_my_const : boolean := false;
  type flag_pt is protected body
    variable flag  : boolean;
    variable flags : boolean;
    constant test  : integer := 1;
  end protected body;

begin

end architecture rtl;

(with type_010) disabled is corrected to

package test is

  type flag_pt is protected

    procedure set;

    procedure clear;

    impure function get return boolean;
  end protected;

end package test;

package body test is

  constant   c_my_const : boolean := false;
  type       flag_pt is protected body
    variable flag       : boolean;
    variable flags      : boolean;
    constant test       : integer := 1;
  end protected body;

end package body test;

architecture rtl of test is

  type flag_pt is protected

    procedure set;

    procedure clear;

    impure function get return boolean;
  end protected;

  constant c_my_const : boolean := false;
  type     flag_pt is protected body
    variable flag     : boolean;
    variable flags    : boolean;
    constant test     : integer := 1;
  end protected body;

begin

end architecture rtl;

Other declarative regions to consider:

JHertz5 commented 5 days ago

I've raised PR #1296 to address this issue.