diff --git a/TODO.md b/TODO.md index 7dc413e..ad03f89 100644 --- a/TODO.md +++ b/TODO.md @@ -6,6 +6,9 @@ TODO call equal_tagged_value() when you find a union type when comparing structs deeply. (C backend, probably others) +There appears to be a bug with casting a union type to +itself? The tag in the tagged value is the union? + Name mangling for compilers (prepend with `_` most likely.) And literal characters in strings, especially `'` and `"`. diff --git a/eg/assoc.castile b/eg/assoc.castile index ceea2a6..cc994b9 100644 --- a/eg/assoc.castile +++ b/eg/assoc.castile @@ -22,7 +22,7 @@ fun lookup(a: assoc, k: string) { return null as string|void } typecase n is assoc { - return lookup(n, k) as string|void + return lookup(n, k) } } diff --git a/tests/Castile.md b/tests/Castile.md index 6a61753..057d9c1 100644 --- a/tests/Castile.md +++ b/tests/Castile.md @@ -827,6 +827,27 @@ Deeply nested structs can be tested for equality. | } = True +Deeply nested structs can be tested for equality, even when containing values +of union type. + + | struct name { first: string; last: string|integer } + | struct person { age: integer; name: name } + | main = fun() { + | j = make person(age: 23, name:make name(first:"Bamber", last:"Smith" as string|integer)); + | k = make person(age: 23, name:make name(first:"Bamber", last:"Smith" as string|integer)); + | j == k + | } + = True + + | struct name { first: string; last: string|integer } + | struct person { age: integer; name: name } + | main = fun() { + | j = make person(age: 23, name:make name(first:"Bamber", last:"Smith" as string|integer)); + | k = make person(age: 23, name:make name(first:"Bamber", last:75 as string|integer)); + | j != k + | } + = True + Structs cannot be compared for ordering. | struct person { age: integer; name: string } @@ -1354,7 +1375,7 @@ One can use this facility to implement abstract data types. | return null as string|void | } | typecase n is assoc { - | return lookup(n, k) as string|void + | return lookup(n, k) | } | } |