Skip to content

Commit ee70928

Browse files
stroxlerfacebook-github-bot
authored andcommitted
Don't early return in expr_infer_type_info_with_hint
Summary: We need to be really careful about early returns in `expr` code, because there are side-effects due to type tracing. Literal string method support added an early return instead of using structured control flow, which turned off type tracing for the methods of string literals. Reviewed By: rchen152 Differential Revision: D80376724 fbshipit-source-id: 6313de2b8fd5c0cd233db984349ebfececab9682
1 parent 2b96bdb commit ee70928

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

pyrefly/lib/alt/expr.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,14 @@ impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> {
238238
let attr_type = self.attr_infer(&base, &x.attr.id, x.range, errors, None);
239239
if base.ty().is_literal_string() {
240240
match attr_type.ty() {
241-
Type::BoundMethod(method) => {
242-
return attr_type
243-
.clone()
244-
.with_ty(method.with_bound_object(base.ty().clone()).as_type());
245-
}
246-
_ => {}
241+
Type::BoundMethod(method) => attr_type
242+
.clone()
243+
.with_ty(method.with_bound_object(base.ty().clone()).as_type()),
244+
_ => attr_type,
247245
}
246+
} else {
247+
attr_type
248248
}
249-
attr_type
250249
}
251250
Expr::Subscript(x) => {
252251
// TODO: We don't deal properly with hint here, we should.

0 commit comments

Comments
 (0)