Repository navigation
fix: CodeAction respects local qualification when filling suggested constraint (#5085) - #5134
Open
blackheaven wants to merge 3 commits into
Open
blackheaven wants to merge 3 commits into
blackheaven wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new partial nameModule call can panic and currently fails HLint.
1 open finding
What changed in this PR
Updates constraint code actions to preserve locally valid qualification.
Changes:
- Adds scope-aware constraint rendering.
- Exports required GHC qualification APIs.
- Adds regression tests for qualified and missing imports.
| File | Description |
|---|---|
CodeAction.hs |
Implements scope-aware rendering. |
Outputable.hs |
Exports qualification primitives. |
Main.hs |
Adds regression coverage. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+1272
to
+1278
| inScope = S.fromList | ||
| [ (moduleName (nameModule nm), occName nm) | ||
| | GRE nm _ _ _ <- globalRdrEnvElts rdrEnv | ||
| ] | ||
| go mdl occ | ||
| | S.member (moduleName mdl, occ) inScope = queryQualifyName defaultCtx mdl occ | ||
| | otherwise = NameUnqual |
…14 queryQualifyName - Filter GlobalRdrEnv names with nameModule_maybe: nameModule is partial for internal Names and can panic; also fixes the hlint restricted-function warning. - Key the in-scope set by full Module (unit + module name) to avoid conflating identically named modules from different units. - GHC 9.14 extended QueryQualifyName with a Maybe ModuleName hint parameter (9.13 dev cycle); pass Nothing under MIN_VERSION_ghc(9,13,0) to fix the 9.14 CI build failure.
queryQualifyName on GHC 9.14 has type Module -> Maybe ModuleName -> OccName -> QualifyName; the override function itself needs the extra parameter, not a dropped argument at the call site.
This branch has not been deployed
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.

A bit of half-way fully vs non-qualified suggestion, see #5085