mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Error evaluating symbolic tuple (#2957)
Reports an error (`value of generic binding T is not known`) instead of performing an invalid cast when attempting to index into a tuple. Can occur when trying to cast a generic constant in the interface position of an implementation to `type`. Closes #2938
This commit is contained in:
@@ -1316,7 +1316,12 @@ auto Interpreter::StepExp() -> ErrorOr<Success> {
|
||||
} else {
|
||||
// { { v :: [][i] :: C, E, F} :: S, H}
|
||||
// -> { { v_i :: C, E, F} : S, H}
|
||||
const auto& tuple = cast<TupleValue>(*act.results()[0]);
|
||||
CARBON_ASSIGN_OR_RETURN(
|
||||
auto converted,
|
||||
Convert(act.results()[0],
|
||||
&cast<IndexExpression>(exp).object().static_type(),
|
||||
exp.source_loc()));
|
||||
const auto& tuple = cast<TupleValue>(*converted);
|
||||
int i = cast<IntValue>(*act.results()[1]).value();
|
||||
if (i < 0 || i >= static_cast<int>(tuple.elements().size())) {
|
||||
return ProgramError(exp.source_loc())
|
||||
|
||||
Reference in New Issue
Block a user