
Matthew Pickering pushed to branch wip/improve-implicit-lifting-error at Glasgow Haskell Compiler / GHC Commits: b82b507e by Matthew Pickering at 2025-05-19T18:14:52+01:00 Refactor the treatment of nested Template Haskell splices * The difference between a normal splice, a quasiquoter and implicit splice caused by lifting is stored in the AST after renaming. * Information that the renamer learns about splices is stored in the relevant splice extension points (XUntypedSpliceExpr, XQuasiQuote). * Normal splices and quasi quotes record the flavour of splice (exp/pat/dec etc) * Implicit lifting stores information about why the lift was attempted, so if it fails, that can be reported to the user. * After renaming, the decision taken to attempt to implicitly lift a variable is stored in the `XXUntypedSplice` extension field in the `HsImplicitLiftSplice` constructor. * Since all the information is stored in the AST, in `HsUntypedSplice`, the type of `PendingRnSplice` now just stores a `HsUntypedSplice`. * Error messages since the original program can be easily printed, this is noticeable in the case of implicit lifting. * The user-written syntax is directly type-checked. Before, some desugaring took place in the * Fixes .hie files to work better with nested splices (nested splices are not indexed) * The location of the quoter in a quasiquote is now located, so error messages will precisely point to it (and again, it is indexed by hie files) In the future, the typechecked AST should also retain information about the splices and the specific desugaring being left to the desugarer. Also, `runRnSplice` should call `tcUntypedSplice`, otherwise the typechecking logic is duplicated (see the `QQError` and `QQTopError` tests for a difference caused by this). - - - - - 43 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Expr.hs-boot - compiler/GHC/Hs/Instances.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Gen/Splice.hs-boot - compiler/GHC/Tc/Types/ErrCtxt.hs - compiler/GHC/Tc/Types/TH.hs - compiler/GHC/Tc/Utils/Concrete.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/ThToHs.hs - compiler/Language/Haskell/Syntax/Expr.hs - compiler/Language/Haskell/Syntax/Extension.hs - testsuite/tests/linters/notes.stdout - testsuite/tests/quotes/LiftErrMsg.stderr - testsuite/tests/quotes/LiftErrMsgDefer.stderr - + testsuite/tests/quotes/LiftErrMsgTyped.hs - + testsuite/tests/quotes/LiftErrMsgTyped.stderr - + testsuite/tests/quotes/QQError.hs - + testsuite/tests/quotes/QQError.stderr - testsuite/tests/quotes/T10384.stderr - testsuite/tests/quotes/TH_localname.stderr - testsuite/tests/quotes/all.T - + testsuite/tests/th/QQInQuote.hs - + testsuite/tests/th/QQTopError.hs - + testsuite/tests/th/QQTopError.stderr - testsuite/tests/th/T10598_TH.stderr - testsuite/tests/th/T14681.stderr - testsuite/tests/th/T17804.stderr - testsuite/tests/th/T5508.stderr - testsuite/tests/th/TH_Lift.stderr - testsuite/tests/th/all.T - testsuite/tests/th/overloaded/TH_overloaded_constraints_fail.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b82b507ee0eef779acb1385d71a63008... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b82b507ee0eef779acb1385d71a63008... You're receiving this email because of your account on gitlab.haskell.org.