Opened 6 years ago

Closed 5 years ago

#2275 closed bug (invalid)

Poor indication of type error location

Reported by: guest Owned by:
Priority: low Milestone: 6.10 branch
Component: Compiler (Type checker) Version: 6.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by igloo)

Using {-# OPTIONS_GHC -XArrows -fno-monomorphism-restriction #-}, and Yampa
Starting from line 32, my program contains:

fireworkSF :: Point2 GL.GLdouble -> Point2 GL.GLdouble -> Object
fireworkSF p0 pFinal = proc _ -> do
  rec
    position <- (p0 .+^) ^<< integral -< v0
    let shouldExplode = position == pFinal
    let killReq = if shouldExplode then Event () else noEvent
    let spawnReq = if shouldExplode
                     then Event (Explode pFinal)
                     else noEvent
  returnA -< ObjectOutput {oState = FireworkState position
                          ,oKillReq = killReq
                          ,oSpawnReq = spawnReq}
  where
    v0 = (pFinal ^-^ p0) ^/ 2

The type error reports:

Firework.hs:32:0:
    Couldn't match expected type `Point2 GL.GLdouble'
           against inferred type `Vector2 GL.GLdouble'
    When using functional dependencies to combine
      AffineSpace (Point2 a) (Vector2 a) a,
        arising from the instance declaration at <no location info>
      AffineSpace (Point2 GL.GLdouble) (Point2 GL.GLdouble) a,
        arising from a use of `.+^' at Firework.hs:34:16-23
    When generalising the type(s) for `fireworkSF'

Indicating that the bug is something to do with line 34. The actual bug is that the last line of the paste should read:

    v0 = (pFinal .-. p0) ^/ 2

Change History (7)

comment:1 Changed 6 years ago by guest

Sorry, here's the code again:

fireworkSF :: Point2 GL.GLdouble -> Point2 GL.GLdouble -> Object
fireworkSF p0 pFinal = proc _ -> do
  rec
    position <- (p0 .+^) ^<< integral -< v0
    let shouldExplode = position == pFinal
    let killReq = if shouldExplode then Event () else noEvent
    let spawnReq = if shouldExplode
                     then Event (Explode pFinal)
                     else noEvent
  returnA -< ObjectOutput {oState = FireworkState position
                          ,oKillReq = killReq
                          ,oSpawnReq = spawnReq}
  where
    v0 = (pFinal ^-^ p0) ^/ 2

And the error:

Firework.hs:32:0:
    Couldn't match expected type `Point2 GL.GLdouble'
           against inferred type `Vector2 GL.GLdouble'
    When using functional dependencies to combine
      AffineSpace (Point2 a) (Vector2 a) a,
        arising from the instance declaration at <no location info>
      AffineSpace (Point2 GL.GLdouble) (Point2 GL.GLdouble) a,
        arising from a use of `.+^' at Firework.hs:34:16-23
    When generalising the type(s) for `fireworkSF'

and the correct line:
v0 = (pFinal .-. p0) ^/

comment:2 Changed 6 years ago by igloo

  • Description modified (diff)
  • Difficulty set to Unknown

comment:3 Changed 6 years ago by simonpj

I can't say I understand just what's going on here. It's difficult to fix this unless we can reproduce it, but you don't give enough information to do that. If you have enough time to upload a reproducible test case, that'd be great.

Simon

comment:4 Changed 6 years ago by igloo

  • Milestone set to 6.10 branch
  • Priority changed from normal to low

comment:5 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:6 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple

comment:7 Changed 5 years ago by igloo

  • Resolution set to invalid
  • Status changed from new to closed

No response from submitter, so closing.

Note: See TracTickets for help on using tickets.