summary refs log tree commit diff stats
path: root/tests/errmsgs/tinvalidinout.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/errmsgs/tinvalidinout.nim')
-rw-r--r--tests/errmsgs/tinvalidinout.nim26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/errmsgs/tinvalidinout.nim b/tests/errmsgs/tinvalidinout.nim
new file mode 100644
index 000000000..268bcf4d5
--- /dev/null
+++ b/tests/errmsgs/tinvalidinout.nim
@@ -0,0 +1,26 @@
+discard """
+cmd: "nim check $file"
+errormsg: "the 'in' modifier can be used only with imported types"
+nimout: '''
+tinvalidinout.nim(14, 7) Error: the 'out' modifier can be used only with imported types
+tinvalidinout.nim(17, 9) Error: the 'in' modifier can be used only with imported types
+tinvalidinout.nim(18, 9) Error: the 'in' modifier can be used only with imported types
+'''
+"""
+
+type
+  Foo[in T] {.header: "foo.h", importcpp.} = object
+
+  Bar[out X] = object
+    x: int
+
+proc f1[in T](x: T) = discard
+proc f2[in T](x: T) {.importc: "f", header: "foo.h"}
+
+var
+  f: Foo[int]
+  b: Bar[string]
+
+f1 f
+f2 b
+