Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#3190 closed bug (invalid)

Type checker fails to unify/expand type definitions in certain contexts

Reported by: ferridder Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 6.10.2
Keywords: Cc:
Operating System: Windows Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

When compiling

type TMvar a = TVar (Maybe a)
mynewEmptyMvar :: STM (TMVar a)
mynewEmptyMvar = newTVar Nothing

the type checker complains

Couldn't match expected type `TMVar a'

against inferred type `TVar (Maybe a1)'

Expected type: STM (TMVar a)
Inferred type: STM (TVar (Maybe a1))

In the expression: newTVar Nothing
In the definition of `mynewEmptyMvar':

mynewEmptyMvar = newTVar Nothing

although the definition of TMvar is
type TMvar a = TVar (Maybe a)

This behaviour could not be duplicated in the IO monad.

Attachments (1)

simple.hs (163 bytes) - added by ferridder 5 years ago.

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by ferridder

comment:1 follow-up: Changed 5 years ago by simonpj

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

Your definition is for TMvar (lower case v). But you used TMVar (upper case V). The latter is defined in Control.Concurrent.STM.TMVar. So the error message is perfectly correct.

I can't see a straightforward way to give a better error message, either.

Simon

comment:2 in reply to: ↑ 1 Changed 5 years ago by ferridder

Thanks, I should have spotted that!

One could display the fully qualified names of (imported only?) constructors as part of the error message, but this might cost more than it's worth.

Another option would be to flag what would be clashes in a case insensitive system as warnings by default, but that would also affect a bunch of legacy code...

Replying to simonpj:

Your definition is for TMvar (lower case v). But you used TMVar (upper case V). The latter is defined in Control.Concurrent.STM.TMVar. So the error message is perfectly correct.

I can't see a straightforward way to give a better error message, either.

Simon

Note: See TracTickets for help on using tickets.