Ticket #1537: donotation.patch

File donotation.patch, 18.4 KB (added by mnislaih, 7 years ago)

patch for HEAD

Line 
1
2New patches:
3
4[Fix #1537 (Generalize typechecking of do notation for rebindable syntax)
5Pepe Iborra <[email protected]>**20071013185110
6   The typechecker didn't handle rebindable syntax for do-notation
7       in full generality. The problem is that it assumes too much about
8       the type of bind, which can be rebinded to something completely
9       different by the user.
10       
11       It is convenient to assume the type of  monadic bind
12       in order to give user friendly error messages, so this patch
13       uses the assumption as long as the NoImplicitPrelude flag is not
14       enabled.
15 
16   MERGE TO STABLE
17 
18] {
19hunk ./compiler/deSugar/DsExpr.lhs 595
20-                                 result_ty (cantFailMatchResult body)
21+                                 (exprType body) (cantFailMatchResult body)
22hunk ./compiler/typecheck/TcMatches.lhs 19
23-                  tcDoStmt, tcMDoStmt, tcGuardStmt
24+                  tcDoStmtSimple, tcMDoStmt, tcGuardStmt
25hunk ./compiler/typecheck/TcMatches.lhs 37
26+import Type
27hunk ./compiler/typecheck/TcMatches.lhs 45
28+import DynFlags
29+
30+import Control.Monad ( liftM )
31hunk ./compiler/typecheck/TcMatches.lhs 244
32-tcDoStmts DoExpr stmts body res_ty
33-  = do { ((m_ty, elt_ty), coi) <- boxySplitAppTy res_ty
34-       ; let res_ty' = mkAppTy m_ty elt_ty     -- The boxySplit consumes res_ty
35-       ; (stmts', body') <- tcStmts DoExpr (tcDoStmt m_ty) stmts
36-                                    (emptyRefinement, res_ty') $
37-                            tcBody body
38-       ; return $ mkHsWrapCoI coi (HsDo DoExpr stmts' body' res_ty') }
39+tcDoStmts DoExpr stmts body res_ty = do
40+  rebind_syntax <- not `liftM` doptM Opt_ImplicitPrelude
41+  if not rebind_syntax
42+    then tcDoStmtsExprSimple stmts body res_ty
43+    else do
44+        ((m_ty, elt_ty), coi) <- boxySplitAppTy res_ty
45+       let res_ty' = mkAppTy m_ty elt_ty       -- The boxySplit consumes res_ty       
46+            reft_res_ty = (emptyRefinement, res_ty')
47+       (stmts', body') <- tcStmts DoExpr tcDoStmt stmts reft_res_ty $
48+                           tcBody body
49+       return $ mkHsWrapCoI coi (HsDo DoExpr stmts' body' res_ty')
50hunk ./compiler/typecheck/TcMatches.lhs 274
51+
52+tcDoStmtsExprSimple stmts body res_ty
53+  = do { ((m_ty, elt_ty), coi) <- boxySplitAppTy res_ty
54+       ; let res_ty' = mkAppTy m_ty elt_ty     -- The boxySplit consumes res_ty
55+       ; (stmts', body') <- tcStmts DoExpr (tcDoStmtSimple m_ty) stmts
56+                                    (emptyRefinement, res_ty') $
57+                            tcBody body
58+       ; return $ mkHsWrapCoI coi (HsDo DoExpr stmts' body' res_ty') }
59+
60hunk ./compiler/typecheck/TcMatches.lhs 420
61-tcDoStmt :: TcType             -- Monad type,  m
62+tcDoStmtSimple :: TcType               -- Monad type,  m
63hunk ./compiler/typecheck/TcMatches.lhs 423
64-tcDoStmt m_ty ctxt (BindStmt pat rhs bind_op fail_op) reft_res_ty@(_,res_ty) thing_inside
65+tcDoStmtSimple m_ty ctxt (BindStmt pat rhs bind_op fail_op) reft_res_ty@(_,res_ty) thing_inside
66hunk ./compiler/typecheck/TcMatches.lhs 447
67-tcDoStmt m_ty ctxt (ExprStmt rhs then_op _) reft_res_ty@(_,res_ty) thing_inside
68+tcDoStmtSimple m_ty ctxt (ExprStmt rhs then_op _) reft_res_ty@(_,res_ty) thing_inside
69hunk ./compiler/typecheck/TcMatches.lhs 449
70-         a_ty <- newFlexiTyVarTy liftedTypeKind
71+         a_ty     <- newFlexiTyVarTy liftedTypeKind
72hunk ./compiler/typecheck/TcMatches.lhs 452
73+       ; rhs'     <- tcPolyExpr rhs rhs_ty
74+       ; then_op' <- tcSyntaxOp DoOrigin then_op then_ty
75+       ; thing    <- thing_inside reft_res_ty
76+       ; return (ExprStmt rhs' then_op' rhs_ty, thing) }
77+
78+tcDoStmtSimple m_ty ctxt stmt res_ty thing_inside
79+  = pprPanic "tcDoStmt: unexpected Stmt" (ppr stmt)
80+
81+
82+tcDoStmt :: TcStmtChecker
83+
84+-- tcDoStmt: the stmt at the lhs of a bind, i.e. (rhs >>= \pat -> thing) :: res_ty
85+tcDoStmt ctxt (BindStmt pat rhs bind_op fail_op) (reft,res_ty) thing_inside
86+  = do {
87+               -- We should use type *inference* for the RHS computations, becuase of GADTs.
88+               --      do { pat <- rhs; <rest> }
89+               -- is rather like
90+               --      case rhs of { pat -> <rest> }
91+               -- We do inference on rhs, so that information about its type can be refined
92+               -- when type-checking the pattern.
93+          m1_ty          <- newFlexiTyVarTy (liftedTypeKind `mkFunTy` liftedTypeKind)
94+        ; (rhs', pat_ty) <- withBox liftedTypeKind $ \pat_ty ->
95+                            tcMonoExpr rhs (mkAppTy m1_ty pat_ty)
96+        ; let rhs_ty      = mkAppTy m1_ty pat_ty
97+        ; m2_ty          <- newFlexiTyVarTy (liftedTypeKind `mkFunTy` liftedTypeKind)
98+        ; b_ty           <- newFlexiTyVarTy liftedTypeKind
99+        ; let thing_ty    = mkAppTy m2_ty b_ty
100+       ; (pat', thing)  <- tcLamPat pat pat_ty (reft, thing_ty)
101+                                              thing_inside
102+
103+       -- Deal with rebindable syntax; (>>=) :: m1 pat_ty -> (pat_ty -> m2 b) -> m3 c
104+       ; let bind_ty = mkFunTys [rhs_ty,
105+                                 mkFunTy pat_ty thing_ty]
106+                                  res_ty
107+       ; bind_op' <- tcSyntaxOp DoOrigin bind_op bind_ty
108+               -- If (but only if) the pattern can fail,
109+               -- typecheck the 'fail' operator
110+       ; fail_op' <- if isIrrefutableHsPat pat'
111+                     then return noSyntaxExpr
112+                     else tcSyntaxOp DoOrigin fail_op (mkFunTy stringTy thing_ty)
113+       ; return (BindStmt pat' rhs' bind_op' fail_op', thing) }
114+-- (rhs >> thing) :: res_ty
115+tcDoStmt ctxt (ExprStmt rhs then_op _) (reft,res_ty) thing_inside
116+  = do {       -- Deal with rebindable syntax; (>>) :: m1 a -> m2 b -> m3 c
117+       ; a_ty  <- newFlexiTyVarTy liftedTypeKind
118+       ; b_ty  <- newFlexiTyVarTy liftedTypeKind
119+       ; m1_ty  <- newFlexiTyVarTy (mkFunTy liftedTypeKind liftedTypeKind)
120+       ; m2_ty  <- newFlexiTyVarTy (mkFunTy liftedTypeKind liftedTypeKind)
121+       ; let then_ty  = mkFunTys [rhs_ty, thing_ty] res_ty
122+              thing_ty = mkAppTy m2_ty b_ty
123+              rhs_ty   = mkAppTy m1_ty a_ty
124hunk ./compiler/typecheck/TcMatches.lhs 504
125-       ; rhs' <- tcPolyExpr rhs rhs_ty
126-       ; thing <- thing_inside reft_res_ty
127+       ; rhs'     <- tcPolyExpr rhs rhs_ty
128+       ; thing    <- thing_inside (reft, thing_ty)
129hunk ./compiler/typecheck/TcMatches.lhs 508
130-tcDoStmt m_ty ctxt stmt res_ty thing_inside
131+tcDoStmt ctxt stmt res_ty thing_inside
132hunk ./compiler/typecheck/TcRnDriver.lhs 1047
133-           tc_io_stmts stmts = tcStmts DoExpr (tcDoStmt io_ty) stmts
134+           tc_io_stmts stmts = tcStmts DoExpr (tcDoStmtSimple io_ty) stmts
135}
136
137Context:
138
139[Fix DoCon: Another try at getting extractResults right
140[email protected]**20071012162325
141 
142 For some reason TcSimplify.extractResults is quite difficult to get right.
143 This is another attempt; finally I think I have it.
144 
145 Strangely enough, it's only Sergey's DoCon program that shows up the
146 bug, which manifested as a failure in the Simplifier
147 
148         lookupRecBndr $dGCDRing{v a1Lz} [lid]
149 
150 But it was due to extractResults producing multiple bindings for
151 the same dictionary.
152 
153 Please merge this to the stable branch (after previous patches to
154 TcSimplify though).
155 
156 
157]
158[mention what SCC stands for
159Simon Marlow <[email protected]>**20071011135736]
160[Add a proper write barrier for MVars
161Simon Marlow <[email protected]>**20071011135505
162 Previously MVars were always on the mutable list of the old
163 generation, which meant every MVar was visited during every minor GC.
164 With lots of MVars hanging around, this gets expensive.  We addressed
165 this problem for MUT_VARs (aka IORefs) a while ago, the solution is to
166 use a traditional GC write-barrier when the object is modified.  This
167 patch does the same thing for MVars.
168 
169 TVars are still done the old way, they could probably benefit from the
170 same treatment too.
171]
172[we need to #include "Stg.h" first, we can't rely on GHC to inject it
173Simon Marlow <[email protected]>**20071010153244
174 This fixes the unreg build, and in general building the RTS code
175 via-C. I'm not sure at what stage this was broken, but I think it
176 was working accidentally before.
177]
178[Fix Trac #1680; check for unboxed tuples in TcType.marshalableTyCon
179[email protected]**20071011123426]
180[Fix Trac #1759: do not let ticks get in the way of spotting trivially-true guards
181[email protected]**20071010164731
182 
183 GHC spots that an 'otherwise' guard is true, and uses that knowledge to
184 avoid reporting spurious missing-pattern or overlaps with -Wall.
185 
186 The HPC ticks were disguising the 'otherwise', which led to this failure.
187 Now we check.  The key change is defining DsGRHSs.isTrueLHsExpr.
188 
189 Test is ds062
190 
191 
192]
193[Fix Trac #1755; check for stage errors in TH quoted Names
194[email protected]**20071010150250
195 
196 There are a number of situations in which you aren't allowed to use
197 a quoted Name in a TH program, such as
198        \x -> 'x
199 But we weren't checking for that!  Now we are.
200 
201 Merge to stable branch.
202 
203 Test is TH_qname.
204 
205 
206]
207[checkWellStaged: reverse comparsion (no change in semantics), plus some comments
208[email protected]**20071010124013]
209[Add traceTc in tcSimplifyDefault
210[email protected]**20071010123933]
211[Improve pretty-printing of splices in HsSyn
212[email protected]**20071010123726]
213[Fix Trac #1678; be more careful about catching and reporting exceptions in spliced TH monadic computations
214[email protected]**20071010145705
215 
216 Many of the new lines are comments to explain the slightly-convoluted
217 in which exceptions get propagated out of the Q monad.
218 
219 This fixes Trac 1679; test is TH_runIO (as well as the exising TH_fail).
220 
221 Please merge
222 
223 
224]
225[Comments only
226[email protected]**20071010145646]
227[FIX BUILD (when compiling base via C): declare n_capabilities
228Simon Marlow <[email protected]>**20071010103704]
229[GHCi: use non-updatable thunks for breakpoints
230Simon Marlow <[email protected]>**20071010093241
231 The extra safe points introduced for breakpoints were previously
232 compiled as normal updatable thunks, but they are guaranteed
233 single-entry, so we can use non-updatable thunks here.  This restores
234 the tail-call property where it was lost in some cases (although stack
235 squeezing probably often recovered it), and should improve
236 performance.
237]
238[FIX #1681: withBreakAction had too large a scope in runStmt
239Simon Marlow <[email protected]>**20071010085820]
240[tiny refactoring
241Simon Marlow <[email protected]>**20071009145002]
242[small reworking of the loop-breaker-choosing algorithm
243Simon Marlow <[email protected]>**20071009145305
244 Previously inline candidates were given higher preference as
245 non-loop-breakers than constructor applications, but the reason for
246 this was that making a wrapper into a loop-breaker is to be avoided at
247 all costs.  This patch refines the algorithm slightly so that wrappers
248 are explicitly avoided by giving them a much higher score, and other
249 inline candidates are given lower scores than constructor
250 applications.
251 
252 This makes almost zero difference to a complete nofib run, so it
253 amounts to just a tidyup.
254]
255[Fix warnings when build w/o readline
256Manuel M T Chakravarty <[email protected]>**20071010101840]
257[Update documentation for win32 DLL linking
258Clemens Fruhwirth <[email protected]>**20071010074415]
259[FIX: tidy up TcSimplify following equality constraints additions
260[email protected]**20071010093334
261 
262 The combination of "type refinement" for GADTs and the new equality
263 constraints has made TcSimplify rather complicated.  And wrong:
264 it generated bogus code for cholewo-eval.
265 
266 This patch is still far from entirely satisfactory.  There are
267 too many places where invariants are unclear, and the code is
268 still a bit of a mess.  But I believe it's better, and it passes
269 the regression tests!  So I think it's good enough for the 6.8 release.
270 
271 Please merge.
272 
273 The main changes are:
274 
275 - get rid of extractLocalResults (which was always suspicious)
276 
277 - instead, treat the 'refinement' along with 'givens', by
278   adding a field to RedEnv, red_reft which travels with red_givens
279 
280 - I also reworked extractResults a bit, which looked wrong to me
281   This entailed changing the Given constructor in Avail to take
282   an Inst rather than a TcId
283 
284 
285]
286[Improve pretty-printing for HsSyn
287[email protected]**20071010093058]
288[Fix Trac #1746: make rule-matching work properly with Cast expressions
289[email protected]**20070929104406
290 
291 The Cast case of the rule-matcher was simply wrong.
292 
293 This patch fixes it; see Trac #1746.
294 
295 I also fixed the rule generation in SpecConstr to generate a wild-card
296 for the cast expression, which we don't want to match on.  This makes
297 the rule more widely applicable; it wasn't the cause of the bug.
298 
299]
300[Small comment only
301[email protected]**20070929104309]
302[export n_capabilities, see #1733
303Simon Marlow <[email protected]>**20071009142701]
304[FIX #1743, create a fresh unique for each Id we bind at a breakpoint
305Simon Marlow <[email protected]>**20071009142554]
306[remove vestiges of way 'u' (see #1008)
307Simon Marlow <[email protected]>**20071009130942]
308[also call initMutex on every task->lock, see #1391
309Simon Marlow <[email protected]>**20071009122409]
310[remove the "-unreg" flag and the unregisterised way, see #1008
311Simon Marlow <[email protected]>**20071009122338]
312[warning removal
313Simon Marlow <[email protected]>**20071009105138]
314[warning removal
315Simon Marlow <[email protected]>**20071003170005]
316[refactoring only: use the parameterised InstalledPackageInfo
317Simon Marlow <[email protected]>**20071003163536
318 This required moving PackageId from PackageConfig to Module
319]
320[warning removal
321Simon Marlow <[email protected]>**20071003174016]
322[warning removal
323Simon Marlow <[email protected]>**20071003173448]
324[warning removal
325Simon Marlow <[email protected]>**20071003173202]
326[warning removal
327Simon Marlow <[email protected]>**20071003172715]
328[remove most warnings
329Simon Marlow <[email protected]>**20071003090804]
330[mkIfaceExports: sort the children of AvailTC
331Simon Marlow <[email protected]>**20071002114917
332 This fixes a problem with spurious recompilations: each time a module
333 was recompiled, the order of the children would change, causing extra
334 recompilation.
335 
336 MERGE TO STABLE
337]
338[error message fix (#1758)
339Simon Marlow <[email protected]>**20071008134958]
340[FIX validate for PPC Mac OS X - RegAllocStats.hs
341Thorkil Naur <[email protected]>**20071005144105]
342[FIX validate for PPC Mac OS X - RegAllocLinear.hs
343Thorkil Naur <[email protected]>**20071005143607]
344[FIX validate for PPC Mac OS X - Linker.c
345Thorkil Naur <[email protected]>**20071005144908]
346[FIX validate for PPC Mac OS X - Evac.h
347Thorkil Naur <[email protected]>**20071005144454]
348[FIX #1748: -main-is wasn't handling the case of a single hierarchical module
349Simon Marlow <[email protected]>**20071008131305
350 test case is driver062.5
351]
352[FIX BUILD FD_SETSIZE signed
353[email protected]**20070927132649
354 On FreeBSD FD_SETSIZE is unsigned. Cast it to a signed int
355 for portability.
356]
357[FIX BUILD addDLL returns const char*
358[email protected]**20070927132619
359 addDLL returns const char*, not just a char*.
360 Fix compiler warning
361]
362[FIX BUILD `set -o igncr'-issue on FreeBSD
363[email protected]**20070926203750
364 `set -o igncr' does not work on non-cygwin-systems.
365 Fail silently if this command does not work, instead
366 of aborting the build.
367 
368]
369[comment-out "use vars" in 3 places (see #1739)
370Simon Marlow <[email protected]>**20071008115740]
371[Change DOCOPTIONS pragma to DOC_OPTIONS
372David Waern <[email protected]>**20071002143849
373 
374 MERGE TO STABLE
375]
376[FIX: parsing of doc options
377David Waern <[email protected]>**20071002143713
378 
379 Lexing of the doc options pragma was changed, but but no change was
380 made to the parser to reflect that. This patch fixes this problem.
381 
382 MERGE TO STABLE
383]
384[FIX: add missing case to OccName.isSymOcc
385David Waern <[email protected]>**20071002143459]
386[Remove warnings from WwLib
387Manuel M T Chakravarty <[email protected]>**20071002130736]
388[FIX: mkWWcpr takes open alg types into account
389Manuel M T Chakravarty <[email protected]>**20071002130407
390 - This fixed the failures of GMapAssoc and GMapTop for optmising ways
391 
392 MERGE TO STABLE
393]
394[FIX #1738: KPush rule of FC must take dataConEqTheta into account
395Manuel M T Chakravarty <[email protected]>**20071001154343
396 
397 MERGE TO STABLE
398]
399[FIX #1729: Don't try to expand syn families with -XLiberalTypeSynonyms
400Manuel M T Chakravarty <[email protected]>**20070929122624
401 
402 MERGE TO STABLE
403]
404[Some more traceTcs
405Manuel M T Chakravarty <[email protected]>**20070929121941]
406[FIX: Make boxy splitters aware of type families
407Manuel M T Chakravarty <[email protected]>**20070928225541
408 
409 MERGE TO STABLE
410]
411[html_installed_root shouldn't contain $$pkgid
412Ian Lynagh <[email protected]>**20070927130427
413 This actually didn't break anything, as the shell expanded $pkgid to the
414 empty string, but it was still wrong.
415]
416[Comments and debug output only
417[email protected]**20070927110842]
418[further stub filename fix: I managed to break non-stubdir -fvia-C compilation
419Simon Marlow <[email protected]>**20070927102539]
420[Finally, I managed to squash an infamous bug in :print
421Pepe Iborra <[email protected]>**20070927151300
422   
423   It turns out the newtype handling code in :print
424   was slipping non mutable Tyvars in the types reconstructed.
425   The error message eventually produced was rather obscure:
426   
427   [src/Tp.hs:75:28-64] *MainTp> :p x
428   *** Exception: No match in record selector Var.tcTyVarDetails
429   [src/Tp.hs:75:28-64] *MainTp>
430   
431   Due to non mutable tyvars, unifyType was failing.
432   A well placed assertion in the unifyType code would have made
433    my life much easier.
434   Which reminds me I should install a -ddump-* system in the
435   RTTI subsystem, or future hackers will run away in swearing.
436 
437 
438 MERGE TO STABLE
439 
440]
441[Be a bit more flexible in terminal identification for do_bold
442Pepe Iborra <[email protected]>**20070927141549
443   
444   In Os X for instance, by default we have TERM=xterm-color
445 
446 MERGE TO STABLE
447 
448]
449[also acquire/release task->lock across fork()
450Simon Marlow <[email protected]>**20070927091331
451 further attempt to fix #1391 on MacOS
452]
453[FIX -stubdir bug: the .hc file was #including the wrong _stub.h filename
454Simon Marlow <[email protected]>**20070926134539
455 Using -stubdir together with hierarchical modules, -fvia-C, and --make
456 is essentially broken in 6.6.x.  Recently discovered by Cabal's use of
457 -stubdir.
458 
459 Test cases: driver027/driver028 (I've updated them to use -fvia-C, in
460 order to test for this bug).
461]
462[Add STANDARD_OPTS to SRC_HC_OPTS in rts/Makefile so we get -I../includes for .cmm files
463Ian Lynagh <[email protected]>**20070926122637
464 Patch from Clemens Fruhwirth
465]
466[fix #1734, panic in :show modules after load failure
467Simon Marlow <[email protected]>**20070926100732]
468[Remove current package from preloaded package set
469Clemens Fruhwirth <[email protected]>**20070926084802]
470[Fixing #1340, adding HPC Documentation
471[email protected]**20070926055331]
472[TAG 2007-09-25
473Ian Lynagh <[email protected]>**20070925164536]
474Patch bundle hash:
4752c0ec348acfa7704d20f3e556fdd5566df6e1c26