Fix false "failed to find library" warning for use clauses of generic packages - #1218
Open
tasgomes wants to merge 1 commit into
Open
Fix false "failed to find library" warning for use clauses of generic packages#1218tasgomes wants to merge 1 commit into
tasgomes wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a design unit brings a locally declared generic package (or a local package instantiation) into scope with a
useclause, the VHDL dependency scanner mistakes the package name for a library name and emits a spurious warning.Example (VHDL-2008 generic package interface):
This produces:
th_pkgis a formal generic-package parameter visible by its simple name, not a library. Compilation and simulation succeed, so only the (misleading) warning is wrong.Root cause
VHDLReference._find_uses()parsesuse th_pkg.all;and records a package reference withlibrary="th_pkg". The parser already recognizes thepackage th_pkg is new work.some_pkg ...instantiation (viaPACKAGE_INSTANCE_PATTERN), but it never uses that knowledge to suppress the bogus library reference, soProjectlater fails to resolve libraryth_pkgand warns.Fix
In
VHDLReference.find(), collect the names introduced by local/generic package instantiations (thenew_namegroup ofPACKAGE_INSTANCE_PATTERN) and drop any package reference whose library matches one of them.The real dependency (the reference to the instantiated package, e.g.
work.some_pkg) haslibrary="work"and is preserved, so the dependency graph is unchanged.Tests
Added
test_use_of_local_package_instance_is_not_a_library_referenceintests/unit/test_vhdl_parser.py, covering both a generic package formal and a local package instance, each followed by ause ...all;clause. It asserts that only the real package references remain. The test fails onmainand passes with this change; the full parser suite still passes.Notes
Fixes a false positive only; the dependency graph and compile order are unaffected.