diff options
Diffstat (limited to 'tests/struct_priv_trait_cont')
| -rw-r--r-- | tests/struct_priv_trait_cont/source.mk | 1 | ||||
| -rw-r--r-- | tests/struct_priv_trait_cont/struct.ek | 32 | ||||
| -rw-r--r-- | tests/struct_priv_trait_cont/struct_priv_trait_cont.ek | 30 |
3 files changed, 63 insertions, 0 deletions
diff --git a/tests/struct_priv_trait_cont/source.mk b/tests/struct_priv_trait_cont/source.mk new file mode 100644 index 0000000..cff75f9 --- /dev/null +++ b/tests/struct_priv_trait_cont/source.mk @@ -0,0 +1 @@ +SIMPLE_XFAIL += struct_priv_trait_cont diff --git a/tests/struct_priv_trait_cont/struct.ek b/tests/struct_priv_trait_cont/struct.ek new file mode 100644 index 0000000..6c94aaa --- /dev/null +++ b/tests/struct_priv_trait_cont/struct.ek @@ -0,0 +1,32 @@ +pub typedef ptr {}; +pub typedef i27 {}; + +pub define trait[] { + do_something(=> i27); +} + +pub typedef implementer {} +continue implementer { + trait![]; + do_something(=> i27) + { + return 0; + } +} + +pub typedef struct[trait T] { + T a; + + call_something(*struct![T] self) + { + self*.a.do_something(); + } +} + +pub some_func() +{ + mut p = struct![implementer]{ + .a = implementer!{} + }; + p.call_something(); +} diff --git a/tests/struct_priv_trait_cont/struct_priv_trait_cont.ek b/tests/struct_priv_trait_cont/struct_priv_trait_cont.ek new file mode 100644 index 0000000..cd67050 --- /dev/null +++ b/tests/struct_priv_trait_cont/struct_priv_trait_cont.ek @@ -0,0 +1,30 @@ +import "struct.ek" + +/* we implement trait here, but there's another private implementation in + * `struct.ek`. Intuitively, I would expect that `p` would end up calling + * this implementation, since without this continuation the code wouldn't + * compile, but the current instanciation/unification system doesn't handle this + * correctly, and the `do_something()` in `struct.ek` is the one that gets + * called (since that's the trait implementation visible to that section of the + * continuation chain). + * + * On a related note, for whatever reason `do_something()` doesn't get written + * by the codegen. Should maybe try and do something about that as well. + */ +continue implementer { + trait![]; + do_something(=> i27) + { + return 1; + } +} + +main() +{ + mut p = struct![implementer]{ + .a = implementer!{} + }; + p.call_something(); + + some_func(); +} |
