mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-27 19:59:07 +00:00
feat: ref/ref!
with type specification
This commit is contained in:
parent
6d2c399d67
commit
1fe189e4d3
4 changed files with 65 additions and 15 deletions
|
@ -466,7 +466,7 @@ impl Context {
|
|||
free_var(level, Constraint::new_type_of(Type))
|
||||
};
|
||||
let spec_t = if let Some(spec_with_op) = &sig.t_spec {
|
||||
match self.instantiate_typespec_full(
|
||||
let t = match self.instantiate_typespec_full(
|
||||
&spec_with_op.t_spec,
|
||||
opt_decl_t,
|
||||
tmp_tv_cache,
|
||||
|
@ -481,6 +481,11 @@ impl Context {
|
|||
}
|
||||
t
|
||||
}
|
||||
};
|
||||
match &sig.pat {
|
||||
ast::ParamPattern::Ref(_) => ref_(t),
|
||||
ast::ParamPattern::RefMut(_) => ref_mut(t, None),
|
||||
_ => t,
|
||||
}
|
||||
} else {
|
||||
match &sig.pat {
|
||||
|
|
|
@ -540,7 +540,8 @@ impl Context {
|
|||
kind,
|
||||
false,
|
||||
) {
|
||||
Ok(ty) => (ty, TyCheckErrors::empty()),
|
||||
Ok(ty @ Type::Ref(_)) => (ty, TyCheckErrors::empty()),
|
||||
Ok(ty) => (ty.into_ref(), TyCheckErrors::empty()),
|
||||
Err((ty, errs)) => (ty, errs),
|
||||
};
|
||||
if &name.inspect()[..] == "self" {
|
||||
|
@ -592,7 +593,8 @@ impl Context {
|
|||
kind,
|
||||
false,
|
||||
) {
|
||||
Ok(ty) => (ty, TyCheckErrors::empty()),
|
||||
Ok(ty @ Type::RefMut { .. }) => (ty, TyCheckErrors::empty()),
|
||||
Ok(ty) => (ty.into_ref_mut(None), TyCheckErrors::empty()),
|
||||
Err((ty, errs)) => (ty, errs),
|
||||
};
|
||||
if &name.inspect()[..] == "self" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue