summaryrefslogtreecommitdiff
path: root/tests/diagnostics
diff options
context:
space:
mode:
Diffstat (limited to 'tests/diagnostics')
-rw-r--r--tests/diagnostics/setter-method.slang23
-rw-r--r--tests/diagnostics/setter-method.slang.expected9
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/diagnostics/setter-method.slang b/tests/diagnostics/setter-method.slang
new file mode 100644
index 000000000..58e7c3417
--- /dev/null
+++ b/tests/diagnostics/setter-method.slang
@@ -0,0 +1,23 @@
+// setter-method.slang
+
+//TEST:SIMPLE:
+
+// Make sure we provide a user a diagnostic if they
+// try to declare a setter method without `mutating`
+// (even if we don't support `mutating` yet).
+
+struct Sphere
+{
+ float3 center;
+ float radius;
+
+ void setCenter(float3 value)
+ {
+ center = value;
+ }
+
+ void setRadius(float value)
+ {
+ this.radius = value;
+ }
+};
diff --git a/tests/diagnostics/setter-method.slang.expected b/tests/diagnostics/setter-method.slang.expected
new file mode 100644
index 000000000..237c499ee
--- /dev/null
+++ b/tests/diagnostics/setter-method.slang.expected
@@ -0,0 +1,9 @@
+result code = -1
+standard error = {
+tests/diagnostics/setter-method.slang(16): error 30011: left of '=' is not an l-value.
+tests/diagnostics/setter-method.slang(16): note 30049: a 'this' parameter is currently immutable in Slang
+tests/diagnostics/setter-method.slang(21): error 30011: left of '=' is not an l-value.
+tests/diagnostics/setter-method.slang(21): note 30049: a 'this' parameter is currently immutable in Slang
+}
+standard output = {
+}