summary refs log tree commit diff stats
path: root/tests/effects
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-10-07 14:38:25 +0200
committerGitHub <noreply@github.com>2020-10-07 14:38:25 +0200
commit0426a4d85ab8f9558dee35c657aad0d299748c15 (patch)
tree14dfd278c4e727f50b0d494100043755ccaee5fe /tests/effects
parentacbe27b082c202895df1b78a82951389b4a232a0 (diff)
downloadNim-0426a4d85ab8f9558dee35c657aad0d299748c15.tar.gz
fixes #15508 (#15509)
Diffstat (limited to 'tests/effects')
-rw-r--r--tests/effects/tfuncs_cannot_mutate_simple.nim21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/effects/tfuncs_cannot_mutate_simple.nim b/tests/effects/tfuncs_cannot_mutate_simple.nim
new file mode 100644
index 000000000..9de20d1ec
--- /dev/null
+++ b/tests/effects/tfuncs_cannot_mutate_simple.nim
@@ -0,0 +1,21 @@
+discard """
+  errormsg: "'edit' can have side effects"
+  nimout: '''an object reachable from 'x' is potentially mutated
+tfuncs_cannot_mutate_simple.nim(17, 4) the mutation is here'''
+  line: 16
+"""
+
+{.experimental: "strictFuncs".}
+
+# bug #15508
+
+type
+  MyType = ref object
+    data: string
+
+func edit(x: MyType) =
+  x.data = "hello"
+
+let x = MyType()
+x.edit()
+echo x.data