Set the value of .Self in a where to that of the outer .Self. (#2344)

Prior to this change, declarations like `let N:! X(.Self) where .(X(.Self).Y) == 5;` have the surprising behavior of the two `.Self` expressions resolving to two different symbolic values. Fix this by forcing the inner one to have the same symbolic value as the outer one, albeit with a different type.
This commit is contained in:
Richard Smith
2022-10-25 11:59:42 -07:00
committed by GitHub
parent c68cced1fb
commit bc7bf325d6
8 changed files with 69 additions and 44 deletions
+1 -4
View File
@@ -1157,12 +1157,9 @@ auto Interpreter::StepExp() -> ErrorOr<Success> {
return todo_.FinishAction(value);
}
case ExpressionKind::DotSelfExpression: {
// `.Self` always symbolically resolves to the self binding, even if it's
// not yet been type-checked.
CARBON_CHECK(act.pos() == 0);
const auto& dot_self = cast<DotSelfExpression>(exp);
return todo_.FinishAction(
arena_->New<VariableType>(&dot_self.self_binding()));
return todo_.FinishAction(*dot_self.self_binding().symbolic_identity());
}
case ExpressionKind::IntLiteral:
CARBON_CHECK(act.pos() == 0);