Don't weaken accessor functions

Accessor functions are equivalent to closures and hence obey function
semantics, no need to weaken them
This commit is contained in:
Ayaz Hafiz 2023-01-12 10:51:13 -06:00 committed by Folkert
parent 0a9155d9d8
commit 2e36e2f418
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -3825,6 +3825,10 @@ fn is_generalizable_expr(mut expr: &Expr) -> bool {
match expr {
Num(..) | Int(..) | Float(..) => return true,
Closure(_) => return true,
Accessor(_) => {
// Accessor functions `.field` are equivalent to closures, no need to weaken them.
return true
},
OpaqueRef { argument, .. } => expr = &argument.1.value,
Str(_) | List { .. } | SingleQuote(_, _, _, _) | When { .. } | If { .. }
| LetRec(_, _, _)
@ -3842,7 +3846,6 @@ fn is_generalizable_expr(mut expr: &Expr) -> bool {
// TODO(weakening)
Var(_, _)
| AbilityMember(_, _, _)
| Accessor(_)
| Update { .. }
| Tag { .. }
| ZeroArgumentTag { .. }