Skip to content

Fix narrow-import diagnostic including transitive types#6

Merged
klaidliadon merged 1 commit into
masterfrom
fix/narrow-import-transitive
Apr 8, 2026
Merged

Fix narrow-import diagnostic including transitive types#6
klaidliadon merged 1 commit into
masterfrom
fix/narrow-import-transitive

Conversation

@klaidliadon
Copy link
Copy Markdown
Collaborator

Summary

  • The "can be narrowed" diagnostic was using the fully resolved schema (including transitive imports) to determine available names from an imported file
  • This caused the narrowing suggestion to include types from transitive imports (e.g. if project.ridl imports common.ridl, narrowing project.ridl would also list common.ridl's types)
  • Switched to locallyDefinedNames(importResult.Root) which only walks the AST of the imported file

Test plan

  • Added TestNarrowImportExcludesTransitiveTypes covering the exact scenario
  • All 116 existing tests pass

The narrowing diagnostic used exportedSchemaNames(importResult.Schema)
which walks the fully resolved schema — including all transitively
imported types. This caused the "can be narrowed" suggestion to list
types from transitive imports (e.g. if project.ridl imports common.ridl,
narrowing project.ridl would also list common.ridl's types).

Switch to locallyDefinedNames(importResult.Root) which walks only the
AST of the imported file, returning just the types/enums/errors/aliases
defined directly in that file.
@klaidliadon klaidliadon merged commit 7a2c17d into master Apr 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant