mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-10 18:08:55 +03:00
Store def name on accessor functions
This commit is contained in:
parent
36f8ed6478
commit
6b491c617e
@ -11,6 +11,7 @@ use crate::annotation::OwnedNamedOrAble;
|
||||
use crate::derive;
|
||||
use crate::env::Env;
|
||||
use crate::expr::get_lookup_symbols;
|
||||
use crate::expr::AccessorData;
|
||||
use crate::expr::AnnotatedMark;
|
||||
use crate::expr::ClosureData;
|
||||
use crate::expr::Declarations;
|
||||
@ -2308,6 +2309,36 @@ fn canonicalize_pending_body<'a>(
|
||||
(loc_can_expr, def_references)
|
||||
}
|
||||
|
||||
// Turn f = .foo into f = \rcd -[f]-> rcd.foo
|
||||
(
|
||||
Pattern::Identifier(defined_symbol)
|
||||
| Pattern::AbilityMemberSpecialization {
|
||||
ident: defined_symbol,
|
||||
..
|
||||
},
|
||||
ast::Expr::RecordAccessorFunction(field),
|
||||
) => {
|
||||
let (loc_can_expr, can_output) = (
|
||||
Loc::at(
|
||||
loc_expr.region,
|
||||
Accessor(AccessorData {
|
||||
name: *defined_symbol,
|
||||
function_var: var_store.fresh(),
|
||||
record_var: var_store.fresh(),
|
||||
ext_var: var_store.fresh(),
|
||||
closure_var: var_store.fresh(),
|
||||
field_var: var_store.fresh(),
|
||||
field: (*field).into(),
|
||||
}),
|
||||
),
|
||||
Output::default(),
|
||||
);
|
||||
let def_references = DefReferences::Value(can_output.references.clone());
|
||||
output.union(can_output);
|
||||
|
||||
(loc_can_expr, def_references)
|
||||
}
|
||||
|
||||
_ => {
|
||||
let (loc_can_expr, can_output) =
|
||||
canonicalize_expr(env, var_store, scope, loc_expr.region, &loc_expr.value);
|
||||
|
@ -2389,6 +2389,17 @@ fn from_can_let<'a>(
|
||||
|
||||
lower_rest!(variable, cont.value)
|
||||
}
|
||||
Accessor(accessor_data) => {
|
||||
let fresh_record_symbol = env.unique_symbol();
|
||||
register_noncapturing_closure(
|
||||
env,
|
||||
procs,
|
||||
*symbol,
|
||||
accessor_data.to_closure_data(fresh_record_symbol),
|
||||
);
|
||||
|
||||
lower_rest!(variable, cont.value)
|
||||
}
|
||||
Var(original, _) | AbilityMember(original, _, _)
|
||||
if procs.get_partial_proc(original).is_none() =>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user