[Issue 18594] X is not an lvalue should have a better error message
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 12 06:00:57 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18594
--- Comment #2 from Seb <greensunny12 at gmail.com> ---
Hmm, just modifying the error message isn't enough. We should probably look up
in the tree to check whether we are in if expression, assert, ...
diff --git a/src/dmd/expression.d b/src/dmd/expression.d
index d93c1ffda..997423b85 100644
--- a/src/dmd/expression.d
+++ b/src/dmd/expression.d
@@ -1855,7 +1855,7 @@ extern (C++) abstract class Expression : RootObject
}
}
}
- error("cannot modify `%s` expression `%s`. Did you mean
`==`?", MODtoChars(type.mod), toChars());
+ error("cannot modify `%s` expression `%s`",
MODtoChars(type.mod), toChars());
return new ErrorExp();
}
else if (!type.isAssignable())
@@ -2604,7 +2604,7 @@ extern (C++) final class IntegerExp : Expression
e = this;
else if (!loc.isValid())
loc = e.loc;
- e.error("constant `%s` is not an lvalue. Did you mean `==`?",
e.toChars());
+ e.error("constant `%s` is not an lvalue", e.toChars());
return new ErrorExp();
}
diff --git a/test/fail_compilation/test18594.d
b/test/fail_compilation/test18594.d
deleted file mode 100644
index 631df3033..000000000
--- a/test/fail_compilation/test18594.d
+++ /dev/null
@@ -1,11 +0,0 @@
-/*TEST_OUTPUT:
----
-fail_compilation/test18594.d(8): Error: constant `1` is not an lvalue. Did you
mean `==`?
-fail_compilation/test18594.d(10): Error: cannot modify `const` expression `a`.
Did you mean `==`?
----
-*/
-void main() {
- assert(1 = 2);
- const a = 1;
- assert(a = 2);
-}
--
More information about the Digitalmars-d-bugs
mailing list