bug (?) in type checking of record update
wanna see a large Int in hugs? I mean Int, not Integer. the program below gives this nice result: Main> contents bug 1000000000000000000000000000000 :: Int data Container a = Container { contents :: a , info :: String } bug :: Container Int bug = let xs = 10^30 a = Container { contents = xs , info = "foo" } in a { info = "bar" } it does so even if i write xs = 10^30 :: Integer I checked with hugs-november-2002. With ghc-5.04.2, without the type sig, ghci converts the numeric expression to an Int (silently overflowing); and with the type sig, it rejects the program. best regards, -- -- Johannes Waldmann ---- http://www.informatik.uni-leipzig.de/~joe/ -- -- joe@informatik.uni-leipzig.de -- phone/fax (+49) 341 9732 204/207 --
On Tue, Feb 04, 2003 at 11:00:16AM +0100, Johannes Waldmann wrote:
wanna see a large Int in hugs? I mean Int, not Integer. the program below gives this nice result:
Main> contents bug 1000000000000000000000000000000 :: Int
data Container a = Container { contents :: a , info :: String }
bug :: Container Int bug = let xs = 10^30 a = Container { contents = xs , info = "foo" } in a { info = "bar" }
Definitely a bug in typing of record updates: Bug> :t Container { contents = True , info = "foo" } { info = "bar" } Container{contents = True, info = "foo"}{info = "bar"} :: Container a
On Tue, Feb 04, 2003 at 10:14:19AM +0000, Ross Paterson wrote:
On Tue, Feb 04, 2003 at 11:00:16AM +0100, Johannes Waldmann wrote:
data Container a = Container { contents :: a , info :: String }
Definitely a bug in typing of record updates:
Bug> :t Container { contents = True , info = "foo" } { info = "bar" } Container{contents = True, info = "foo"}{info = "bar"} :: Container a
This was introduced in the last release. Here's a patch that reverses it, but presumably something more refined is needed to achieve the original aim: Index: src/type.c =================================================================== RCS file: /home/cvs/root/hugs98/src/type.c,v retrieving revision 1.62 diff -u -r1.62 type.c --- src/type.c 23 Jan 2003 17:47:08 -0000 1.62 +++ src/type.c 4 Feb 2003 10:28:08 -0000 @@ -1814,11 +1814,8 @@ instantiate(t); shouldBe(line,snd(f),e,update,arg(fun(tr)),or); } /* Unmentioned component */ - /* this is just a sanity check, and avoiding it lets us - handle records with polymoprhic components else if (!unify(arg(fun(td)),od,arg(fun(tr)),or)) internal("typeUpdFlds"); - */ tr = arg(tr); td = arg(td);
participants (2)
-
Johannes Waldmann -
Ross Paterson