summary refs log tree commit diff stats
path: root/tests/fields/tfields_in_template.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fields/tfields_in_template.nim')
-rw-r--r--tests/fields/tfields_in_template.nim15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/fields/tfields_in_template.nim b/tests/fields/tfields_in_template.nim
new file mode 100644
index 000000000..9352a7a51
--- /dev/null
+++ b/tests/fields/tfields_in_template.nim
@@ -0,0 +1,15 @@
+discard """
+  output: '''n
+n'''
+"""
+
+# bug #1902
+# This works.
+for name, value in (n: "v").fieldPairs:
+  echo name
+
+# This doesn't compile - "expression 'name' has no type (or is ambiguous)".
+template wrapper: stmt =
+  for name, value in (n: "v").fieldPairs:
+    echo name
+wrapper()