lang: Add a new type unification test

I wanted to make sure that the type unification algorithm restricts the
implementation of the class when included, when one of the polymorphic
types is specified with a fixed type. It seems this works! I had the
idea for this test while walking around aimlessly.
This commit is contained in:
James Shubin
2019-04-24 03:46:21 -04:00
parent d70bbfb5d0
commit 63ef11c708
2 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1 @@
# err: err3: can't unify, invariant illogicality with equals: base kind does not match (2 != 5)

View File

@@ -0,0 +1,12 @@
import "fmt"
# note that the class can have two separate types for $b
include c1("t1", "hello") # len is 5
include c1("t2", [13, 42, 0, -37,]) # len is 4
# specifying a fixed type for $b is a compile error, because it's sometimes str!
class c1($a, $b []str) {
test $a {
anotherstr => fmt.printf("len is: %d", len($b)),
}
}