summary refs log tree commit diff stats
path: root/tests/errmsgs/tmetaobjectfields.nim
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-04-26 22:05:03 +0800
committerGitHub <noreply@github.com>2024-04-26 16:05:03 +0200
commitf682dabf71f35833e934a79007906f94d8d32c92 (patch)
treefcf6ecd98957bbc83d0d51665468537ed5d2c44a /tests/errmsgs/tmetaobjectfields.nim
parent0b0f185bd1db2500079aefd888078b6bd1094270 (diff)
downloadNim-f682dabf71f35833e934a79007906f94d8d32c92.tar.gz
fixes #23531; fixes invalid meta type accepted in the object fields (#23532)
fixes #23531
fixes #19546
fixes #6982
Diffstat (limited to 'tests/errmsgs/tmetaobjectfields.nim')
-rw-r--r--tests/errmsgs/tmetaobjectfields.nim61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/errmsgs/tmetaobjectfields.nim b/tests/errmsgs/tmetaobjectfields.nim
new file mode 100644
index 000000000..837041512
--- /dev/null
+++ b/tests/errmsgs/tmetaobjectfields.nim
@@ -0,0 +1,61 @@
+discard """
+  cmd: "nim check --hints:off $file"
+  action: "reject"
+  nimout: '''
+tmetaobjectfields.nim(24, 5) Error: 'array' is not a concrete type
+tmetaobjectfields.nim(28, 5) Error: 'seq' is not a concrete type
+tmetaobjectfields.nim(32, 5) Error: 'set' is not a concrete type
+tmetaobjectfields.nim(35, 3) Error: 'sink' is not a concrete type
+tmetaobjectfields.nim(37, 3) Error: 'lent' is not a concrete type
+tmetaobjectfields.nim(54, 16) Error: 'seq' is not a concrete type
+tmetaobjectfields.nim(58, 5) Error: 'ptr' is not a concrete type
+tmetaobjectfields.nim(59, 5) Error: 'ref' is not a concrete type
+tmetaobjectfields.nim(60, 5) Error: 'auto' is not a concrete type
+tmetaobjectfields.nim(61, 5) Error: 'UncheckedArray' is not a concrete type
+'''
+"""
+
+
+# bug #6982
+# bug #19546
+# bug #23531
+type
+  ExampleObj1 = object
+    arr: array
+
+type
+  ExampleObj2 = object
+    arr: seq
+
+type
+  ExampleObj3 = object
+    arr: set
+
+type A = object
+  b: sink
+  # a: openarray
+  c: lent
+
+type PropertyKind = enum
+  tInt,
+  tFloat,
+  tBool,
+  tString,
+  tArray
+
+type
+  Property = ref PropertyObj
+  PropertyObj = object
+    case kind: PropertyKind
+    of tInt: intValue: int
+    of tFloat: floatValue: float
+    of tBool: boolValue: bool
+    of tString: stringValue: string
+    of tArray: arrayValue: seq
+
+type
+  RegressionTest = object
+    a: ptr
+    b: ref
+    c: auto
+    d: UncheckedArray