mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-27 19:59:07 +00:00
fix: const attribute/method evaluation bugs (2)
This commit is contained in:
parent
987b5f1f99
commit
b0d75dba36
1 changed files with 12 additions and 10 deletions
|
@ -754,14 +754,16 @@ impl Context {
|
||||||
|
|
||||||
fn tp_eval_const_call(&self, call: &Call) -> Failable<TyParam> {
|
fn tp_eval_const_call(&self, call: &Call) -> Failable<TyParam> {
|
||||||
if let Some(attr) = &call.attr_name {
|
if let Some(attr) = &call.attr_name {
|
||||||
let obj = self.eval_const_expr(&call.obj);
|
let res_obj = self.eval_const_expr(&call.obj);
|
||||||
let callee = match obj.clone() {
|
let mut is_method = true;
|
||||||
|
let callee = match res_obj.clone() {
|
||||||
Ok(obj) => self
|
Ok(obj) => self
|
||||||
.eval_attr(obj, attr)
|
.eval_attr(obj, attr)
|
||||||
.map_err(|err| (TyParam::Failure, err.into()))?,
|
.map_err(|err| (TyParam::Failure, err.into()))?,
|
||||||
Err((_val, errs)) => {
|
Err((_val, errs)) => {
|
||||||
let acc = Accessor::attr(*call.obj.clone(), attr.clone());
|
let acc = Accessor::attr(*call.obj.clone(), attr.clone());
|
||||||
self.eval_const_acc(&acc)
|
self.eval_const_acc(&acc)
|
||||||
|
.inspect(|_| is_method = false)
|
||||||
.map_err(|(_val, _errs)| (TyParam::Failure, errs))?
|
.map_err(|(_val, _errs)| (TyParam::Failure, errs))?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -787,14 +789,14 @@ impl Context {
|
||||||
Ok(args) => (args, EvalErrors::empty()),
|
Ok(args) => (args, EvalErrors::empty()),
|
||||||
Err((args, es)) => (args, es),
|
Err((args, es)) => (args, es),
|
||||||
};
|
};
|
||||||
if subr.sig_t().is_method() {
|
let obj = match res_obj {
|
||||||
let obj = match obj {
|
Ok(obj) => obj,
|
||||||
Ok(obj) => obj,
|
Err((obj, es)) => {
|
||||||
Err((obj, es)) => {
|
errs.extend(es);
|
||||||
errs.extend(es);
|
obj
|
||||||
obj
|
}
|
||||||
}
|
};
|
||||||
};
|
if is_method {
|
||||||
args.pos_args.insert(0, obj);
|
args.pos_args.insert(0, obj);
|
||||||
}
|
}
|
||||||
let tp = match self.call(subr.clone(), args, call.loc()) {
|
let tp = match self.call(subr.clone(), args, call.loc()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue