X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Ftests%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftests%2Fscl%2FPolymorphicRecursion.scl;fp=bundles%2Forg.simantics.scl.compiler%2Ftests%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftests%2Fscl%2FPolymorphicRecursion.scl;h=ed84193b7f62339402e9499424e56622a7d3c8c2;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/scl/PolymorphicRecursion.scl b/bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/scl/PolymorphicRecursion.scl new file mode 100644 index 000000000..ed84193b7 --- /dev/null +++ b/bundles/org.simantics.scl.compiler/tests/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