Ticket #1333 (closed bug: fixed)

Opened 6 years ago

Last modified 2 years ago

core lint failures from arrow notation + HPC

Reported by: igloo Owned by:
Priority: high Milestone: 7.0.2
Component: Compiler Version: 6.7
Keywords: Cc: ross@…, andygill@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: arrowrun001 arrowrun002 arrowrun003 Blocked By:
Blocking: Related Tickets:

Description

Test arrowrun001 the ghci way gives a core lint error:

*** Core Lint Errors: in result of Desugar ***
<no location info>:
    In the expression: {tick (main:Main, 38)}_dOu
             @ (GHC.Base.Bool -> Main.Exp -> Main.Exp -> GHC.Prim.State# GHC.Prim.RealWorld)
             b_axo
    b_axo is out of scope
*** Offending Program ***
[...]

arrowrun002 and arrowrun003 also have core lint failures that, at least, look superficially similar.

arrowrun004 has a different looking core lint failure, and it happens for all ways:

*** Core Lint Errors: in result of Desugar ***
<no location info>:
    In the expression: >>>_aLC @ () @ () @ GHC.Base.Int
    >>>_aLC is out of scope
*** Offending Program *** 
[...]

Change History

Changed 6 years ago by simonpj

I think that arrowrun004 is another case of #1080, which Ross is looking at.

However arrowrun001 is different. Its triggered by an interaction of

  • the tick-boxes added by Andy Gill's HPC coverage tool, which is always on for GHCi, because the tick-boxes are used for debugging too
  • the desugaring of Ross Paterson's arrow syntax

If you go:

ghc  -dcore-lint -ddump-tc arrowrun001.hs --interactive 

you'll get the dump below (interesting lines marked ***; some stuff elided). The problem is that the HPC tool inserts a tick-box that says that b_av8 is in scope, but the desugaring for the arrow-syntax has taken it out of scope.

I propose to leave it to Andy and Ross to fight it out.

Simon

==================== Typechecker ====================
....	 ....

      eval (If e1 e2 e3)
	     = proc env -> do ~(Bl b) <- eval e1 -< env
			      if b then eval e2 -< env else eval e3 -< env
....	 ....



*** Core Lint Errors: in result of Desugar ***
<no location info>:
    In the expression: {tick (main:Main, 38)}_dGx
			 @ (GHC.Base.Bool -> Main.Exp -> Main.Exp -> GHC.Prim.State# GHC.Prim.RealWorld)
			 b_av8
    b_av8 is out of scope
*** Offending Program ***

....	 ....

	    Main.If e1_av2 e2_av3 e3_av4 ->
	      __letrec {
....	 ....
		>>>_aBS
		  @ [(Main.Id, Main.Val a_awZ)]
		  @ [(Main.Id, Main.Val a_awZ)]
		  @ (Main.Val a_awZ)
		  (arr_aBR
		     @ [(Main.Id, Main.Val a_awZ)]
		     @ [(Main.Id, Main.Val a_awZ)]
		     (\ (env_av6 :: [(Main.Id, Main.Val a_awZ)]) -> env_av6))
		  (>>>_aBS
		     @ [(Main.Id, Main.Val a_awZ)]
		     @ ([(Main.Id, Main.Val a_awZ)], GHC.Base.Bool)
		     @ (Main.Val a_awZ)
		     (>>>_aBS
			@ [(Main.Id, Main.Val a_awZ)]
			@ ([(Main.Id, Main.Val a_awZ)], [(Main.Id, Main.Val a_awZ)])
			@ ([(Main.Id, Main.Val a_awZ)], GHC.Base.Bool)
			(arr_aBR
			   @ [(Main.Id, Main.Val a_awZ)]
			   @ ([(Main.Id, Main.Val a_awZ)], [(Main.Id, Main.Val a_awZ)])
			   (\ (ds_dGG :: [(Main.Id, Main.Val a_awZ)]) ->
			      let {
				env_av6 :: [(Main.Id, Main.Val a_awZ)]
				[]
				env_av6 = ds_dGG
			      } in  (env_av6, env_av6)))
			(>>>_aBS
			   @ ([(Main.Id, Main.Val a_awZ)], [(Main.Id, Main.Val a_awZ)])
			   @ (Main.Val a_awZ, [(Main.Id, Main.Val a_awZ)])
			   @ ([(Main.Id, Main.Val a_awZ)], GHC.Base.Bool)
			   (first_aBT
			      @ [(Main.Id, Main.Val a_awZ)]
			      @ (Main.Val a_awZ)
			      @ [(Main.Id, Main.Val a_awZ)]
			      (case {tick (main:Main, 34)}_dGD
				      @ (Main.Exp -> GHC.Prim.State# GHC.Prim.RealWorld) e1_av2
			       of tick_dGE { __DEFAULT ->
			       >>>_aBS
				 @ [(Main.Id, Main.Val a_awZ)]
				 @ [(Main.Id, Main.Val a_awZ)]
				 @ (Main.Val a_awZ)
				 (arr_aBR
				    @ [(Main.Id, Main.Val a_awZ)]
				    @ [(Main.Id, Main.Val a_awZ)]
				    (\ (ds_dGC :: [(Main.Id, Main.Val a_awZ)]) ->
				       let {
					 env_av6 :: [(Main.Id, Main.Val a_awZ)]
					 []
					 env_av6 = ds_dGC
				       } in  env_av6))
				 (case {tick (main:Main, 33)}_dGz
					 @ (Main.Exp -> GHC.Prim.State# GHC.Prim.RealWorld) e1_av2
				  of tick_dGA { __DEFAULT ->
				  eval_aBI e1_av2
				  })
			       }))
			   (arr_aBR
			      @ (Main.Val a_awZ, [(Main.Id, Main.Val a_awZ)])
			      @ ([(Main.Id, Main.Val a_awZ)], GHC.Base.Bool)
			      (\ (ds_dGO :: (Main.Val a_awZ, [(Main.Id, Main.Val a_awZ)])) ->
				 case ds_dGO of ds_dGO { (ds_dGJ, ds_dGH) ->
				 let {
				   ds_dGK :: Main.Val a_awZ
				   []
				   ds_dGK = ds_dGJ } in
				 let {
				   ds_dGL :: ()
				   []
				   ds_dGL =
				     GHC.Err.irrefutPatError @ () "arrowrun001.hs:(21,21)-(24,21)|(Main.Bl b)" } in
				 let {
				   b_av8 :: GHC.Base.Bool
				   []
***				   b_av8 =
				     let {
				       fail_dGM :: GHC.Base.Bool
				       []
				       fail_dGM = ds_dGL `cast` (CoUnsafe () GHC.Base.Bool :: () ~ GHC.Base.Bool)
				     } in 
				       case ds_dGK of wild_B1 {
					 __DEFAULT -> fail_dGM; Main.Bl b_av8 -> __letrec { } in  b_av8
				       } } in
				 let {
				   env_av6 :: [(Main.Id, Main.Val a_awZ)]
				   []
				   env_av6 = ds_dGH
				 } in  (env_av6, b_av8)
				 }))))
		     (case {tick (main:Main, 38)}_dGx
			     @ (GHC.Base.Bool -> Main.Exp -> Main.Exp -> GHC.Prim.State# GHC.Prim.RealWorld)
***			     b_av8
			     e2_av3
			     e3_av4
		      of tick_dGy { __DEFAULT ->
		      >>>_aBS
			@ ([(Main.Id, Main.Val a_awZ)], GHC.Base.Bool)
			@ (Data.Either.Either [(Main.Id, Main.Val a_awZ)] [(Main.Id, Main.Val a_awZ)])
			@ (Main.Val a_awZ)
			(arr_aBR
			   @ ([(Main.Id, Main.Val a_awZ)], GHC.Base.Bool)
			   @ (Data.Either.Either [(Main.Id, Main.Val a_awZ)] [(Main.Id, Main.Val a_awZ)])
			   (\ (ds_dGw :: ([(Main.Id, Main.Val a_awZ)], GHC.Base.Bool)) ->
***			      case ds_dGw of ds_dGw { (env_av6, b_av8) ->
			      case case {tick (main:Main, 35)}_dGl @ (GHC.Prim.State# GHC.Prim.RealWorld)
				   of tick_dGm { __DEFAULT ->
				   b_av8
				   }
			      of wild_B1 {
				GHC.Base.False ->
				  Data.Either.Right
				    @ [(Main.Id, Main.Val a_awZ)] @ [(Main.Id, Main.Val a_awZ)] env_av6;
				GHC.Base.True ->
				  Data.Either.Left
				    @ [(Main.Id, Main.Val a_awZ)] @ [(Main.Id, Main.Val a_awZ)] env_av6
			      }
			      }))
...

Changed 6 years ago by ross

  • testcase changed from arrowrun001 arrowrun004 to arrowrun001 arrowrun002 arrowrun003
  • summary changed from core lint failures in arrow tests to core lint failures from arrow notation + HPC

Created a separate bug report (#1662) for arrowrun004, which is a different issue.

Changed 6 years ago by ross

This input expression

proc env -> do
        ~(Bl b) <- eval e1 -< env
        if b    then eval e2 -< env
                else eval e3 -< env

is turned into this prior to desugaring:

proc
  ((env{v auF} [lid] :: [(Id{tc rsH}, Val{tc rsD} a{tv awm} [sk])]))
  ->
  do ~(Bl{d rsF} ((b{v auH} [lid] :: Bool{(w) tc 3c}))) <-
        tick<34>(e1{v auB}
                 [lid]tick<33>(e1{v auB} [lid]eval{v aAK} [lid] e1{v auB} [lid]) -<
                 env{v auF} [lid])
       tick<38>(b{v auH} [lid] e2{v auC} [lid] e3{v auD} [lid]
        if tick<35>(b{v auH} [lid]) then
                tick<36>(e2{v auC} [lid]eval{v aAO} [lid] e2{v auC} [lid]) -<
                        env{v auF} [lid]
            else
                tick<37>(e3{v auD} [lid]eval{v aAR} [lid] e3{v auD} [lid]) -<
                        env{v auF} [lid])

This not legal in arrow notation, for which the bindings of a pattern in do notation are not in scope for the whole of subsequent statements, just the expressions to the right of -<.

Changed 6 years ago by ross

In the above example, the problematic variable is auH. The use in the condition of the if is OK; it's the one outside the if that is the problem.

Changed 6 years ago by simonpj

Ross, Andy

Thanks for investigating, Ross. Can you two work together to figure out together what is the Right Thing to do here? Ross knows arrows, Andy knows hpc.

Thanks!

Simon

Changed 6 years ago by simonmar

  • cc Ross, Paterson, <ross@…>, Andy, Gill, <andy@…> added

CC'ing Ross and Andy. Any idea what's going on here?

Changed 6 years ago by simonmar

  • cc ross@…, andy@… added; Ross, Paterson, <ross@…>, Andy, Gill, <andy@…> removed

Changed 5 years ago by igloo

  • milestone changed from 6.8 branch to 6.10 branch

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 4 years ago by igloo

  • milestone changed from 6.10 branch to 6.12 branch

Changed 3 years ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

Changed 3 years ago by igloo

  • priority changed from normal to high
  • failure set to None/Unknown
  • milestone changed from 6.12.3 to 6.14.1

Changed 3 years ago by simonmar

I think this is causing the test T3822(ghci) to fail, so I'm marking it as such.

Changed 3 years ago by ross

I think the problem here is adding these annotations to if, case, etc commands, which are not expressions. It's a bit tricky because commands have the same representation (HsExp?) as expressions: the distinction comes from the context in which they are used. Commands occur inside proc expressions, and can themselves contain expressions. The way this is handled in most traversals of expressions is to pass an environment that differs between commands and expressions.

Changed 3 years ago by simonmar

  • cc andygill@… added; andy@… removed

Changed 3 years ago by simonmar

Andy, Ross: just a heads up, if you'd like this fixed for the release, then there's a short window during which to do so (about 3 weeks).

Changed 3 years ago by simonpj

Ross, Andy

Just to say that GHC 7.0 is going to go out without fixing this HPC/Arrows interaction.

We’re about to produce release candidate 2; and expect to release shortly after.

Are you ok with leaving the bug in?

Simon

Changed 2 years ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

Changed 2 years ago by ross

  • status changed from new to merge

Fixed by

Wed Feb  2 21:14:25 GMT 2011  Ross Paterson <ross@soi.city.ac.uk>
  * avoid adding HPC ticks to arrow constructs (fixes #1333)

Changed 2 years ago by igloo

  • status changed from merge to closed
  • resolution set to fixed

Thanks Ross! Merged.

Note: See TracTickets for help on using tickets.