fix(base-db): handle included SystemVerilog files as include-only units#29
Merged
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.
Closes #27, should be merge after #32.
When a
.svfile is reached through a SystemVerilog`includeand is also discovered by the workspace scan as a standalone source file, semantic compilation can add the same physical file twice.In projects without an explicit config, Vizsla currently treats scanned
.svfiles as semantic roots. For a layout like:z_frag.svis first assigned by slang while preprocessinga_pkg.sv, then Vizsla later tries to addz_frag.svagain as an independent compilation root. slang rejects the duplicate source-manager path and aborts with:This crashes the language server process.
Change
This PR builds a preprocessor file index from slang directive trivia and uses it to classify literal include targets.
`includetargets..svfiles reached by literal includes as include-only units..svfiles from standalone semantic roots.Follow-up
While investigating the LSP crashes, we found a second, separate crash class: semantic requests can also abort when stale borrowed slang syntax nodes outlive their backing
SyntaxTree.That issue is not caused by duplicate include buffers and is intentionally not fixed here. It is handled in #31, which makes semantics syntax ownership explicit and replaces long-lived borrowed syntax nodes/tokens with stable syntax pointers.