Skip to content

Instantly share code, notes, and snippets.

@wbbradley
Last active August 26, 2016 03:43
Show Gist options
  • Save wbbradley/3deea5bfc7da984f3bf7957e506f603f to your computer and use it in GitHub Desktop.
Save wbbradley/3deea5bfc7da984f3bf7957e506f603f to your computer and use it in GitHub Desktop.
module _
# test: pass
type C{T} is
Ax(T, int, float) or
Bx(int, T, float) or
Cx(int, float, T)
def main()
a_int := Ax(4, 5, 2.1)
b_int := Bx(4, 5, 2.1)
c_str := Cx(4, 5.2, "hello")
ALL_TESTS=1 ./zion test
info: ------ running test_complex_sum ------
info: creating unchecked type C
info: evaluating type term (ref str)
info: creating bound type for (ref str)
info: evaluating type term (ref int)
info: creating bound type for (ref int)
info: evaluating type term (fn (args str) int)
info: resolving types in module:std
info: resolving types in module:tests/test_complex_sum
info: checking module level type `C`@tests/test_complex_sum.zion:4:6
info: creating sum type term with type variables [T] that is
Ax((ref T), (ref int), (ref float)) or
Bx((ref int), (ref T), (ref float)) or
Cx((ref int), (ref float), (ref T))
info: registering type term Ax as (lambda T (tagged-tuple (tag Ax) (and (ref T) (ref int) (ref float))))
info: adding `Ax`@tests/test_complex_sum.zion:5:5 as an unchecked generic data_ctor
info: registering type term Bx as (lambda T (tagged-tuple (tag Bx) (and (ref int) (ref T) (ref float))))
info: adding `Bx`@tests/test_complex_sum.zion:6:5 as an unchecked generic data_ctor
info: registering type term Cx as (lambda T (tagged-tuple (tag Cx) (and (ref int) (ref float) (ref T))))
info: adding `Cx`@tests/test_complex_sum.zion:7:5 as an unchecked generic data_ctor
info: registering type term C as (lambda T (or (ref Ax T) (ref Bx T) (ref Cx T)))
info: resolving variables in module:std
info: checking module level variable `print`@lib/std.zion:5:5
info: `print`@lib/std.zion:5:5 is generic
info: resolving variables in module:tests/test_complex_sum
info: checking module level variable `main`@tests/test_complex_sum.zion:9:5
info: `main`@tests/test_complex_sum.zion:9:5 is fully bound
info: type checking `main`@tests/test_complex_sum.zion:9:5 in program-tests/test_complex_sum::test_complex_sum
info: evaluating type term (fn (args) void)
info: creating bound type for (fn (args) void)
info: creating function main with LLVM type void ()
info: `main`@tests/test_complex_sum.zion:9:5 is fully bound
info: type checking statement var a_int = Ax(4, 5, 2.1)
info: reference_expr::resolve_overrides for Ax(4, 5, 2.1)
info: checking whether Ax : `Ax`@tests/test_complex_sum.zion:5:5 : (fn (args (ref T) (ref int) (ref float)) (tagged-tuple (tag Ax) (and (ref T) (ref int) (ref float)))) accepts (args int int float)
info: unify((fn (args (ref T) (ref int) (ref float)) (tagged-tuple (tag Ax) (and (ref T) (ref int) (ref float)))), (fn (args int int float) (any __1)), {C: (lambda T (or (ref Ax T) (ref Bx T) (ref Cx T))), Ax: (lambda T (tagged-tuple (tag Ax) (and (ref T) (ref int) (ref float)))), Bx: (lambda T (tagged-tuple (tag Bx) (and (ref int) (ref T) (ref float)))), Cx: (lambda T (tagged-tuple (tag Cx) (and (ref int) (ref float) (ref T))))})
tests/test_complex_sum.zion:10:11: error: unable to resolve overloads for Ax. arguments are (args int int float).
tests/test_complex_sum.zion:5:5: error: Ax : `Ax`@tests/test_complex_sum.zion:5:5 : (fn (args (ref T) (ref int) (ref float)) (tagged-tuple (tag Ax) (and (ref T) (ref int) (ref float))))
info: type checking statement var b_int = Bx(4, 5, 2.1)
info: type checking statement var c_str = Cx(4, 5.2, "hello")
info: checking module level variable `Ax`@tests/test_complex_sum.zion:5:5
info: checking module level variable `Bx`@tests/test_complex_sum.zion:6:5
info: checking module level variable `Cx`@tests/test_complex_sum.zion:7:5
info: type checking found errors
error: compilation of tests/test_complex_sum failed when it should have passed.
info:
--- test program listing of tests/test_complex_sum ---
module test_complex_sum
type C{T} is
Ax((ref T), (ref int), (ref float)) or
Bx((ref int), (ref T), (ref float)) or
Cx((ref int), (ref float), (ref T))
def main()
var a_int = Ax(4, 5, 2.1)
var b_int = Bx(4, 5, 2.1)
var c_str = Cx(4, 5.2, "hello")
error: ------ ✗ test_complex_sum FAILED ------
error: ====== 0/125 TESTS PASSED (1 failures, 124 skipped) ======
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment