Fix mismatch_assignment error reported for generic arguments using items imported at an enclosing scope - #3121
Merged
dalance merged 1 commit intoAug 2, 2026
Conversation
taichi-ishitani
force-pushed
the
fix_import_visibility_in_nested_scope
branch
2 times, most recently
from
July 31, 2026 06:04
6937d97 to
79c1a3c
Compare
…items imported at an enclosing scope (refs: veryl-lang#3120)
taichi-ishitani
force-pushed
the
fix_import_visibility_in_nested_scope
branch
from
August 2, 2026 01:28
79c1a3c to
b6ac5ae
Compare
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.
fix #3120
Cause
scope::is_importedonly inspected theimport/ wildcard bindings declared directly in the given scope, without walking toward the enclosing scopes. Its two helpers are documented as such:imports_get: "Returns the explicitimportbindings ofnamedirectly inscope."wildcards_get: "Returns the wildcard imports declared directly inscope."So a reference made from inside a generate block asked the wrong scope:
is_importedhead_already_qualifiedinst bazModule25Htruefalseinst uModule25H::gfalsetrueOnce the qualification is skipped,
baz_1_2stays unqualified. Inunalias_innerthe loop then starts at the alias itself instead of its containing package, soPacakge25Gis never visited and its gen-const map{BAZ_0_VALUE: 1, BAZ_1_VALUE: 2}is never pushed ontogeneric_maps.apply_mapruns with an empty map,BAZ_0_VALUEis left unsubstituted, andGenericSymbol::mangled()drops the arguments altogether because one of them still refers to aGenericConst:The two
baz_ifsignatures then disagree,Signature::is_compatiblefails ongeneric_parameters, andmismatch_assignmentis reported for the port connection:Fix
scope::is_importednow walks from the query scope toward the enclosing scopes, stopping at the module / interface / package containing it, sinceimportis not visible across a container boundary.The two ifdef-related checks are carried over verbatim. In particular
b.define_context == dctxstays an equality, so a reference inside an#[ifdef]-guarded generate block still does not see an unguardedimportof its container. That is unchanged from the current behaviour (the nested scope holds no bindings today either), and relaxing it would alter ifdef visibility semantics on its own, so it is left out of this fix.