diff options
| author | 2026-10-12 08:46:23 +0330 | |
|---|---|---|
| committer | 2026-10-12 08:46:23 +0330 | |
| commit | ecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch) | |
| tree | 70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /tests/programs/methodown.zc | |
a
Diffstat (limited to 'tests/programs/methodown.zc')
| -rw-r--r-- | tests/programs/methodown.zc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/programs/methodown.zc b/tests/programs/methodown.zc new file mode 100644 index 0000000..98ba146 --- /dev/null +++ b/tests/programs/methodown.zc @@ -0,0 +1,15 @@ +// a struct method can return an owned object: its header declares the .u return +struct Node { int v; } +struct Maker { + static Node*.u make(int n) { Node* p = new(Node); p.v = n; return u*p; } +} +Node*.u mk(int n) { Node* p = new(Node); p.v = n; return u*p; } +int main() { + Node*.u a = Maker.make(7); + put_n(a.v); put_c(32); + free(d*a); + Node*.u b = mk(9); + put_n(b.v); put_c(10); + free(d*b); + return 0; +} |
