IndexerExpression#GetReference(): ref, not copy, index if it's a literal string

This commit is contained in:
Alexander A. Klimov 2022-11-10 12:49:11 +01:00
parent 73e2a367ed
commit d072c6bc22

View file

@ -792,8 +792,14 @@ bool IndexerExpression::GetReference(ScriptFrame& frame, bool init_dict, Value *
*parent = operand1.GetValue();
}
ExpressionResult operand2 = m_Operand2->Evaluate(frame);
index->Set(operand2.GetValue());
auto lit (dynamic_cast<LiteralExpression*>(m_Operand2.get()));
if (lit && lit->GetValue().IsString()) {
index->Set(&lit->GetValue().Get<String>());
} else {
ExpressionResult operand2 = m_Operand2->Evaluate(frame);
index->Set(operand2.GetValue());
}
if (dhint) {
if (psdhint)