summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-03-07 14:57:47 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2022-03-24 09:00:06 +0000
commit5440e8794bf8ccca291e649dd1a19b8302203de6 (patch)
tree8dccec3f1e28b4e1fb364668335ba0e912bfaea8
parente6585ca168ba55ca81a3e6cd7221707719b7fa56 (diff)
downloadhaskell-wip/rn-ast-ghci.tar.gz
Make -ddump-rn-ast and -ddump-tc-ast work in GHCiwip/rn-ast-ghci
Fixes #17830
-rw-r--r--compiler/GHC/Tc/Module.hs6
-rw-r--r--testsuite/tests/ghci/scripts/T17830.script2
-rw-r--r--testsuite/tests/ghci/scripts/T17830.stdout356
-rwxr-xr-xtestsuite/tests/ghci/scripts/all.T2
4 files changed, 365 insertions, 1 deletions
diff --git a/compiler/GHC/Tc/Module.hs b/compiler/GHC/Tc/Module.hs
index e690d1e5a2..d8ec1e1b16 100644
--- a/compiler/GHC/Tc/Module.hs
+++ b/compiler/GHC/Tc/Module.hs
@@ -2241,6 +2241,9 @@ tcUserStmt :: GhciLStmt GhcPs -> TcM (PlanResult, FixityEnv)
-- An expression typed at the prompt is treated very specially
tcUserStmt (L loc (BodyStmt _ expr _ _))
= do { (rn_expr, fvs) <- checkNoErrs (rnLExpr expr)
+
+ ; dumpOptTcRn Opt_D_dump_rn_ast "Renamer" FormatHaskell
+ (showAstData NoBlankSrcSpan NoBlankEpAnnotations rn_expr)
-- Don't try to typecheck if the renamer fails!
; ghciStep <- getGhciStepIO
; uniq <- newUnique
@@ -2337,6 +2340,9 @@ tcUserStmt (L loc (BodyStmt _ expr _ _))
then no_it_plans
else it_plans
+ ; dumpOptTcRn Opt_D_dump_tc_ast "Typechecker AST" FormatHaskell
+ (showAstData NoBlankSrcSpan NoBlankEpAnnotations plan)
+
; fix_env <- getFixityEnv
; return (plan, fix_env) }
diff --git a/testsuite/tests/ghci/scripts/T17830.script b/testsuite/tests/ghci/scripts/T17830.script
new file mode 100644
index 0000000000..65f353d816
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T17830.script
@@ -0,0 +1,2 @@
+:set -ddump-parsed-ast -ddump-rn-ast -ddump-tc-ast
+1
diff --git a/testsuite/tests/ghci/scripts/T17830.stdout b/testsuite/tests/ghci/scripts/T17830.stdout
new file mode 100644
index 0000000000..02724f13a7
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T17830.stdout
@@ -0,0 +1,356 @@
+
+==================== Parser AST ====================
+
+(Just
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <interactive>:2:1 })
+ (BodyStmt
+ (NoExtField)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <interactive>:2:1 })
+ (HsOverLit
+ (EpAnn
+ (Anchor
+ { <interactive>:2:1 }
+ (UnchangedAnchor))
+ (NoEpAnns)
+ (EpaComments
+ []))
+ (OverLit
+ (NoExtField)
+ (HsIntegral
+ (IL
+ (SourceText 1)
+ (False)
+ (1))))))
+ (NoExtField)
+ (NoExtField))))
+
+
+
+==================== Renamer ====================
+
+(L
+ (SrcSpanAnn (EpAnnNotUsed) { <interactive>:2:1 })
+ (HsOverLit
+ (EpAnn
+ (Anchor
+ { <interactive>:2:1 }
+ (UnchangedAnchor))
+ (NoEpAnns)
+ (EpaComments
+ []))
+ (OverLit
+ (OverLitRn
+ (False)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ {Name: fromInteger}))
+ (HsIntegral
+ (IL
+ (SourceText 1)
+ (False)
+ (1))))))
+
+
+
+==================== Typechecker AST ====================
+
+((,)
+ [{Var: it_azr}]
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ (XExpr
+ (WrapExpr
+ (HsWrap
+ (WpLet
+ ({abstract:TcEvBinds}))
+ (HsDo
+ (TyConApp
+ ({abstract:TyCon})
+ [(TyConApp
+ ({abstract:TyCon})
+ [(TyConApp
+ ({abstract:TyCon})
+ [])])])
+ (GhciStmtCtxt)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ [(L
+ (SrcSpanAnn (EpAnnNotUsed) { <interactive>:2:1 })
+ (LetStmt
+ (EpAnnNotUsed)
+ (HsValBinds
+ (EpAnnNotUsed)
+ (XValBindsLR
+ (NValBinds
+ [((,)
+ (NonRecursive)
+ {Bag(LocatedA (HsBind Var)):
+ [(L
+ (SrcSpanAnn (EpAnnNotUsed) { <interactive>:2:1 })
+ (AbsBinds
+ (NoExtField)
+ [{Var: a_aP2[sk:1]}]
+ [{Var: $dNum_aP5}]
+ [(ABE
+ (NoExtField)
+ {Var: it_azr}
+ {Var: it_aOZ}
+ (WpHole)
+ (SpecPrags
+ []))]
+ [({abstract:TcEvBinds})]
+ {Bag(LocatedA (HsBind Var)):
+ [(L
+ (SrcSpanAnn (EpAnnNotUsed) { <interactive>:2:1 })
+ (FunBind
+ (WpHole)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <interactive>:2:1 })
+ {Var: it_aOZ})
+ (MG
+ (MatchGroupTc
+ []
+ (TyVarTy
+ {Var: a_aP2[tau:1]}))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ [(L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ (Match
+ (EpAnnNotUsed)
+ (FunRhs
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <interactive>:2:1 })
+ {Var: it_aOZ})
+ (Prefix)
+ (NoSrcStrict))
+ []
+ (GRHSs
+ (EpaComments
+ [])
+ [(L
+ (SrcSpanAnn
+ (EpAnnNotUsed)
+ { <no location info> })
+ (GRHS
+ (EpAnnNotUsed)
+ []
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <interactive>:2:1 })
+ (HsOverLit
+ (EpAnnNotUsed)
+ (OverLit
+ (OverLitTc
+ (False)
+ (HsApp
+ (EpAnnNotUsed)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ (XExpr
+ (WrapExpr
+ (HsWrap
+ (WpCompose
+ (WpEvApp
+ (EvExpr
+ (Var
+ {Var: $dNum_aP3})))
+ (WpTyApp
+ (TyVarTy
+ {Var: a_aP2[tau:1]})))
+ (HsVar
+ (NoExtField)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ {Var: fromInteger}))))))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ (HsLit
+ (EpAnnNotUsed)
+ (HsInteger
+ (SourceText 1)
+ (1)
+ (TyConApp
+ ({abstract:TyCon})
+ [])))))
+ (TyVarTy
+ {Var: a_aP2[tau:1]}))
+ (HsIntegral
+ (IL
+ (SourceText 1)
+ (False)
+ (1))))))))]
+ (EmptyLocalBinds
+ (NoExtField)))))])
+ (FromSource))
+ []))]}
+ (False)))]})]
+ [])))))
+ ,(L
+ (SrcSpanAnn (EpAnnNotUsed) { <interactive>:2:1 })
+ (BodyStmt
+ (TyConApp
+ ({abstract:TyCon})
+ [(TyVarTy
+ {Var: a_aPf[tau:0]})])
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ (HsApp
+ (EpAnnNotUsed)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ (XExpr
+ (WrapExpr
+ (HsWrap
+ (WpCompose
+ (WpEvApp
+ (EvExpr
+ (Var
+ {Var: $dShow_aPi})))
+ (WpTyApp
+ (TyVarTy
+ {Var: a_aPh[tau:0]})))
+ (HsVar
+ (NoExtField)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ {Var: print}))))))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ (XExpr
+ (WrapExpr
+ (HsWrap
+ (WpCompose
+ (WpEvApp
+ (EvExpr
+ (Var
+ {Var: $dNum_aPk})))
+ (WpTyApp
+ (TyVarTy
+ {Var: a_aPj[tau:0]})))
+ (HsVar
+ (NoExtField)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ {Var: it_azr}))))))))
+ (SyntaxExprTc
+ (XExpr
+ (WrapExpr
+ (HsWrap
+ (WpCompose
+ (WpTyApp
+ (TyVarTy
+ {Var: b_aPg[tau:0]}))
+ (WpTyApp
+ (TyVarTy
+ {Var: a_aPf[tau:0]})))
+ (HsVar
+ (NoExtField)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ {Var: GHC.Base.thenIO})))))
+ [(WpHole)
+ ,(WpHole)]
+ (WpHole))
+ (NoSyntaxExprTc)))
+ ,(L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ (LastStmt
+ (NoExtField)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ (HsApp
+ (EpAnn
+ (Anchor
+ { placeholder:-1:-1 }
+ (UnchangedAnchor))
+ (NoEpAnns)
+ (EpaComments
+ []))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ (XExpr
+ (WrapExpr
+ (HsWrap
+ (WpTyApp
+ (TyConApp
+ ({abstract:TyCon})
+ [(TyConApp
+ ({abstract:TyCon})
+ [])]))
+ (HsVar
+ (NoExtField)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ {Var: GHC.Base.returnIO}))))))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ (ExplicitList
+ (TyConApp
+ ({abstract:TyCon})
+ [])
+ [(L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ (HsApp
+ (EpAnn
+ (Anchor
+ { placeholder:-1:-1 }
+ (UnchangedAnchor))
+ (NoEpAnns)
+ (EpaComments
+ []))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ (XExpr
+ (WrapExpr
+ (HsWrap
+ (WpCompose
+ (WpCompose
+ (WpCompose
+ (WpTyApp
+ (TyConApp
+ ({abstract:TyCon})
+ []))
+ (WpTyApp
+ (ForAllTy
+ (Bndr
+ {Var: a_aP2[sk:1]}
+ (Invisible
+ (InferredSpec)))
+ (FunTy
+ (InvisArg)
+ (TyConApp
+ ({abstract:TyCon})
+ [])
+ (TyConApp
+ ({abstract:TyCon})
+ [(TyVarTy
+ {Var: a_aP2[sk:1]})])
+ (TyVarTy
+ {Var: a_aP2[sk:1]})))))
+ (WpTyApp
+ (TyConApp
+ ({abstract:TyCon})
+ [])))
+ (WpTyApp
+ (TyConApp
+ ({abstract:TyCon})
+ [])))
+ (HsVar
+ (NoExtField)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ {Var: Unsafe.Coerce.unsafeCoerce#}))))))
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ (HsVar
+ (NoExtField)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { <no location info> })
+ {Var: it_azr})))))]))))
+ (Nothing)
+ (NoSyntaxExprTc)))])))))))
+
+
+1
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 08e431ef33..f2d03bd8cf 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -366,4 +366,4 @@ test('T20974', normal, ghci_script, ['T20974.script'])
test('T21088', normal, ghci_script, ['T21088.script'])
test('T21110', [extra_files(['T21110A.hs'])], ghci_script,
['T21110.script'])
-
+test('T17830', [filter_stdout_lines(r'======.*')], ghci_script, ['T17830.script'])