X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=tests%2Forg.simantics.scl.compiler.tests%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftests%2Fscl%2FPolymorphicRecursion.scl;fp=tests%2Forg.simantics.scl.compiler.tests%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftests%2Fscl%2FPolymorphicRecursion.scl;h=ed84193b7f62339402e9499424e56622a7d3c8c2;hb=0364f8f54b009e9e5de482d5c9d1cb7efb023141;hp=0000000000000000000000000000000000000000;hpb=7ecf07ff9aacab300f1fb900f1f0f97beb1be139;p=simantics%2Fplatform.git diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/PolymorphicRecursion.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/PolymorphicRecursion.scl new file mode 100644 index 000000000..ed84193b7 --- /dev/null +++ b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/PolymorphicRecursion.scl @@ -0,0 +1,16 @@ +// Idea here is to test the following property: +// When a function is called recursively it has locally a monomorphic type. +// Therefore the definition of cons does not work even if it works +// with a proper type annotation. + +data Vec a = Nil | Zero (Vec (a,a)) | One a (Vec (a,a)) + +// cons :: a -> Vec a -> Vec a +cons x Nil = One x Nil +cons x (Zero ps) = One x ps +cons x (One y ps) = Zero (cons (x, y) ps) +-- +11:21-11:42: Expected got . +11:33-11:34: Type (a, a) is not a subtype of a. +11:36-11:37: Type (a, a) is not a subtype of a. +11:39-11:41: Expected got . \ No newline at end of file