ggreif / omega

Automatically exported from code.google.com/p/omega
Other
7 stars 0 forks source link

feasibility of syntax extension constructors not validated #77

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It is possible to derive syntax extensions where the constructors adhere by 
arity but are not typeable:

$ cat test.omg 
data Foo :: * where
  Nu :: Foo
  Co :: Int -> Int -> Foo
 deriving List(f)

$ ./omega.exe test.omg 
Omega Interpreter: version 1.4.6
Build Date: Fri May  7 10:18:58 Pacific Daylight Time 2010

Type ':?' for command line help.
Loading source files = ["test.omg"]
->Loading import test.omg
<-test.omg loaded.
prompt> [1,2]f

In the expression: Nu
the result type: Foo
was not what was expected: Int

truths:

different constants
   Foo   !=   Int
(Foo,Int)
prompt> []f

[]f : Foo
prompt> [1]f

In the expression: Nu
the result type: Foo
was not what was expected: Int

truths:

different constants
   Foo   !=   Int
(Foo,Int)
prompt> Co 1 2

omega.exe: Value.hs:(233,0)-(236,47): Non-exhaustive patterns in function 
showVcon

As you can see from the transcript, type errors and even internal errors happen 
when the constructors are malformed.
This should be pre-checked when "deriving" instead of accepted blindly.

Original issue reported on code.google.com by ggr...@gmail.com on 3 Dec 2010 at 4:51

GoogleCodeExporter commented 9 years ago
see also issue 17

Original comment by ggr...@gmail.com on 5 Dec 2010 at 7:00

GoogleCodeExporter commented 9 years ago
see checkDerivs in Infer.hs where to apply the fix.

Original comment by ggr...@gmail.com on 1 Jan 2011 at 11:47