jeremiah-c-leary / vhdl-style-guide

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

VSG crashes when the `package` keyword is the first word in the file #1100

Closed JHertz5 closed 5 months ago

JHertz5 commented 5 months ago

Environment VHDL Style Guide (VSG) version: 3.20.0.dev5 Git commit SHA: e41bdd88

Describe the bug The following snippet will cause VSG to fail with a Python error when attempting to fix errors.

package my_package is

end package;

I suspect that this is similar to #1091.

To Reproduce Steps to reproduce the behavior:

  1. Create a file, test.vhd with the following contents:
    
    package my_package is

end package;

2. Run `vsg -f test.vhd --fix`
3. See the follwing output:

$ ./bin/vsg -f test.vhd --fix multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker result = (True, func(*args, **kwds)) File "/bin/../vsg/apply_rules.py", line 125, in apply_rules oRules.fix( File "/bin/../vsg/rule_list.py", line 160, in fix oRule.fix(self.oVhdlFile, dFixOnly) File "/bin/../vsg/rule.py", line 106, in fix self.analyze(oFile) File "/bin/../vsg/rules/align_tokens_in_region_between_tokens_skipping_lines_starting_with_tokens.py", line 65, in analyze lToi = oFile.get_tokens_bounded_by(self.left_token, self.right_token, bIncludeTillBeginningOfLine=True) File "/bin/../vsg/vhdlFile/vhdlFile.py", line 231, in get_tokens_bounded_by return extract.get_tokens_bounded_by(oLeft, oRight, self.lAllObjects, self.oTokenMap, include_trailing_whitespace=include_trailing_whitespace, bExcludeLastToken=bExcludeLastToken, bIncludeTillEndOfLine=bIncludeTillEndOfLine, bIncludeTillBeginningOfLine=bIncludeTillBeginningOfLine) File "/bin/../vsg/vhdlFile/extract/get_tokens_bounded_by.py", line 53, in get_tokens_bounded_by oStart = lAllObjects[iStart] IndexError: list index out of range """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/./bin/vsg", line 15, in main() File "/bin/../vsg/main.py", line 153, in main for tResult in pool.imap(f, enumerate(commandLineArguments.filename)): File "/usr/lib/python3.10/multiprocessing/pool.py", line 873, in next raise value IndexError: list index out of range

JHertz5 commented 5 months ago

This is exactly the same bug as #1091, I just hadn't updated my fork to include that change :( Closing.