| 53 | } |
| 54 | |
| 55 | void ImmutableValidator::analyseVariableReference(Declaration const* _reference, Expression const& _expression) |
| 56 | { |
| 57 | auto const* variable = dynamic_cast<VariableDeclaration const*>(_reference); |
| 58 | if (!variable || !variable->isStateVariable() || !variable->immutable()) |
| 59 | return; |
| 60 | |
| 61 | // If this is not an ordinary assignment, we write and read at the same time. |
| 62 | if (_expression.annotation().willBeWrittenTo) |
| 63 | m_errorReporter.typeError( |
| 64 | 1581_error, |
| 65 | _expression.location(), |
| 66 | "Cannot write to immutable here: Immutable variables can only be initialized inline or assigned directly in the constructor." |
| 67 | ); |
| 68 | } |
nothing calls this directly
no test coverage detected