summary refs log tree commit diff stats
path: root/tests/discard/tneedsdiscard_in_for.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/discard/tneedsdiscard_in_for.nim')
-rw-r--r--tests/discard/tneedsdiscard_in_for.nim22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/discard/tneedsdiscard_in_for.nim b/tests/discard/tneedsdiscard_in_for.nim
new file mode 100644
index 000000000..7685bd577
--- /dev/null
+++ b/tests/discard/tneedsdiscard_in_for.nim
@@ -0,0 +1,22 @@
+discard """
+  errormsg: '''expression 'premultiply(app.gradient[i])' is of type 'Rgba8' and has to be used (or discarded)'''
+  line: 22
+"""
+
+# bug #9076
+type
+  Rgba8 = object
+
+proc premultiply*(c: var Rgba8): var Rgba8 =
+  return c
+
+type
+  App = ref object
+    gradient: seq[Rgba8]
+
+method onDraw(app: App) {.base.} =
+  var
+    width  = 100'f64
+
+  for i in 0..<width.int:
+    app.gradient[i].premultiply()