Open wS-SM opened 2 years ago
In the compiler we must convert the lvalue (int&) to an rvalue (expression result), and there is no conversion back after that. This has been the behavior since at least 1.9. In C++ this works because its type system is much finer grained and more formally specified. It has the concept of "expression that is an l-value" and our compiler does not. Eg, this would probably work in C++:
(c ? a : b) = 5;
Anyway, I'm not super excited to try and fix this - it'd be very invasive to the semantic analysis pass and is too risky for 1.11. In addition not many languages would match C++'s behavior. C#, which has reference types, matches SourcePawn here.
sm 1.10-1.11 In C++ this works, but SourcePawn is drunk =)