last can't be used to write into Arrays
Summary
Symbolic expressions currently return by const reference which doesn't allow to overwrite their content
Environment
Bug is probably environment independent.
- Operating System : Windows
- Architecture : x64
- Eigen Version : 3.4.0
- Compiler Version : MSVC 2022
- Compile Flags : /O2
Minimal Example
ArrayXd Vector = ArrayXd::Zero( 2048 );
Vector( Vector.size() - 1 ) = 1; // legal
Vector( last ) = 1; // Error: expression must be a modifiable lvalue
Steps to reproduce
Just writing in an Array/Matrix using "last" as an "index"
What is the current bug behavior?
This prevents compilation.
What is the expected correct behavior?
Writing into the last Array entry.
Relevant logs
clang output:
> ...
> function 'operator()<Eigen::symbolic::SymbolExpr<Eigen::internal::symbolic_last_tag>>' which returns const-qualified type 'std::enable_if_t<symbolic::is_symbolic<SymbolExpr<symbolic_last_tag>>::value, CoeffReturnType>' (aka 'const double &') declared here
> std::enable_if_t<symbolic::is_symbolic<IndexType>::value, CoeffReturnType >
> ^~~~~~~~~~~~~~~~~~~
Potential fixes
Probably not returning a const value