lang/interpret_test/TestAstFunc1/polydoubleincludewithtype.txtar
raw| 1 | -- main.mcl -- |
| 2 | import "fmt" |
| 3 | |
| 4 | # note that the class can have two separate types for $b |
| 5 | include c1("t1", "hello") # len is 5 |
| 6 | include c1("t2", [13, 42, 0, -37,]) # len is 4 |
| 7 | |
| 8 | # specifying a fixed type for $b is a compile error, because it's sometimes str! |
| 9 | class c1($a, $b []str) { |
| 10 | test "${a}" { |
| 11 | anotherstr => fmt.printf("len is: %d", len($b)), |
| 12 | } |
| 13 | } |
| 14 | -- OUTPUT -- |
| 15 | # err: errUnify: unify error with: str("hello"): type error: list != str |