Skip to content

fix: CodeAction respects local qualification when filling suggested constraint (#5085) - #5134

Open
blackheaven wants to merge 3 commits into
haskell:masterfrom
blackheaven:fix/codeaction-constraint-qualified
Open

blackheaven wants to merge 3 commits into
haskell:masterfrom
blackheaven:fix/codeaction-constraint-qualified

Conversation

@blackheaven

Copy link
Copy Markdown
Collaborator

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



Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

No deployments
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.

2 participants