aboutsummaryrefslogtreecommitdiff
path: root/tests/defer_shadow.ek
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-08-12 18:55:46 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-08-12 19:06:03 +0300
commit2157fdbaca0b80e488c4f77ad5c0d04b051175cf (patch)
tree6a6ba7be30b2eb32219cd9aa2eb30c3bddacd5b4 /tests/defer_shadow.ek
parentce6ba9e8d260e43d11518688363229755a212472 (diff)
downloadek-2157fdbaca0b80e488c4f77ad5c0d04b051175cf.tar.gz
ek-2157fdbaca0b80e488c4f77ad5c0d04b051175cf.zip
make defer work better with generic code
Diffstat (limited to 'tests/defer_shadow.ek')
-rw-r--r--tests/defer_shadow.ek28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/defer_shadow.ek b/tests/defer_shadow.ek
new file mode 100644
index 0000000..0e890a2
--- /dev/null
+++ b/tests/defer_shadow.ek
@@ -0,0 +1,28 @@
+typedef i9 {}
+typedef i27 {}
+
+define any[] {}
+
+extern _putchar(i9 c);
+
+typedef some_struct[any T] {
+ test()
+ {
+ i9 a = 'a' as i9;
+ {
+ /* at this point, only a is defined */
+ defer _putchar(a);
+
+ /* a gets shadowed */
+ i9 a = 'b' as i9;
+
+ /* defer should still point to the outer 'a' */
+ }
+ }
+}
+
+main()
+{
+ some_struct![i9] test = some_struct![i9]{};
+ test.test();
+}