MCPcopy Create free account
hub / github.com/argotorg/solidity / analyseVariableReference

Method analyseVariableReference

libsolidity/analysis/ImmutableValidator.cpp:55–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void 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}

Callers

nothing calls this directly

Calls 4

immutableMethod · 0.80
typeErrorMethod · 0.80
isStateVariableMethod · 0.45
locationMethod · 0.45

Tested by

no test coverage detected