mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 10:51:05 +01:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user