[Issue 18594] X is not an lvalue should have a better error message

2023-05-09 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18594

RazvanN  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||razvan.nitu1...@gmail.com
 Resolution|--- |FIXED

--- Comment #7 from RazvanN  ---
This issue has been fixed by: https://github.com/dlang/dmd/pull/8009

--


[Issue 18594] X is not an lvalue should have a better error message

2022-12-17 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18594

Iain Buclaw  changed:

   What|Removed |Added

   Priority|P1  |P4

--


[Issue 18594] X is not an lvalue should have a better error message

2022-02-22 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18594

du...@neet.fi changed:

   What|Removed |Added

 CC||du...@neet.fi

--- Comment #6 from du...@neet.fi ---
the same error message is given when taking the address of a non-lvalue, but
"cannot be modified" doesn't necessarily apply there (and can be confusing)

// Error: `a[0..2]` is not an lvalue and cannot be modified
ubyte[2] a;
const void* p1 = [0..2];

// Error: cannot modify constant `1`
const void* p2 = &1;

for these, the message should rather say something like "cannot have its
address taken"

--


[Issue 18594] X is not an lvalue should have a better error message

2019-09-25 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18594

Tobias Pankrath  changed:

   What|Removed |Added

 CC||tob...@pankrath.net

--- Comment #5 from Tobias Pankrath  ---
---
struct Test(T) {

@property ref T get() inout { return member; }

private:
   T member;
}


int main(string[] args)
{
   Test!int t;
   t.get = 12;
   return t.get;
}
---

This code has an very similar issue:

> test.d(3): Error: cast(int)this.member is not an lvalue and cannot be modified

The correct definition is:
---
struct Test(T) {

@property ref inout(T) get() inout { return member; }

private:
   T member;
}
---

but the error message gives no hint in that direction. It confused me quite a
bit, since IMO member is a fine lvalue that happens to be const/inout. 

https://run.dlang.io/is/IJKZ80

--


[Issue 18594] X is not an lvalue should have a better error message

2018-04-05 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18594

--- Comment #4 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/ea309c0967e473db3c19e202ffcaf563d9cfff63
Issue 12663, 18594 - Replace lvalue in error messages with 'cannot modify'

https://github.com/dlang/dmd/commit/4574f6891b925c768382ae6dba57b93c4b66bf13
Merge pull request #8009 from wilzbach/fix-18594

Issue 18594 - Replace lvalue in error messages with 'cannot modify'
merged-on-behalf-of: Mike Franklin 

--


[Issue 18594] X is not an lvalue should have a better error message

2018-03-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18594

--- Comment #3 from Seb  ---
A start: https://github.com/dlang/dmd/pull/8009

--


[Issue 18594] X is not an lvalue should have a better error message

2018-03-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18594

--- Comment #2 from Seb  ---
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..0
--- 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);
-}

--


[Issue 18594] X is not an lvalue should have a better error message

2018-03-11 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18594

Seb  changed:

   What|Removed |Added

Summary|constant 1 is not an lvalue |X is not an lvalue should
   |should have a better error  |have a better error message
   |message |

--