add note about VRP not applying to assignment operator exps#23101
add note about VRP not applying to assignment operator exps#23101WalterBright wants to merge 1 commit into
Conversation
What does that mean? |
|
I'm not sure, but it looks like your parentheses are unbalanced here. |
|
It's opening a double link |
|
@dkorpel thanks! |
| the binary operators. Still the left operand must be an lvalue. | ||
| ) | ||
|
|
||
| $(P $(DDSUBLINK spec/type.html, vrp, Value Range Propagation) does not apply to assignment operator expressions:) |
There was a problem hiding this comment.
VRP is part of implicit conversions. For built-in types, a op= b is defined as doing a cast / explicit conversion, so VRP isn't even a possibility. And for custom types, where an implicit conversion happens to the argument type, VRP does apply:
struct S
{
auto opOpAssign(string op)(ubyte value)
{
return this;
}
}
void f(S b, uint i)
{
b *= i; // Error
b *= i & 0xFF; // No error
}So the statement is either irrelevant or incorrect, it's best left out.
There was a problem hiding this comment.
The spec for a op= b can certainly be adapted to do VRP. As for opOpAssign, it is up to the user implementation of it to use VRP or not.
There was a problem hiding this comment.
it is up to the user implementation of it to use VRP or not.
Then the PR should demonstrate that instead of stating something false.
For reference: #19075 (comment)