mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-28 12:14:43 +00:00
feat: add Record.as_dict()
This commit is contained in:
parent
2966497ad6
commit
5e71bd7fd0
6 changed files with 96 additions and 4 deletions
|
@ -1338,6 +1338,13 @@ impl Context {
|
|||
}
|
||||
Ok(TyParam::Set(new_set))
|
||||
}
|
||||
TyParam::Record(dict) => {
|
||||
let mut fields = dict! {};
|
||||
for (name, tp) in dict.into_iter() {
|
||||
fields.insert(name, self.eval_tp(tp)?);
|
||||
}
|
||||
Ok(TyParam::Record(fields))
|
||||
}
|
||||
TyParam::Type(t) => self
|
||||
.eval_t_params(*t, self.level, &())
|
||||
.map(TyParam::t)
|
||||
|
@ -2345,6 +2352,14 @@ impl Context {
|
|||
}
|
||||
Ok(set_t(union, len))
|
||||
}
|
||||
TyParam::Record(dict) => {
|
||||
let mut fields = dict! {};
|
||||
for (name, tp) in dict.into_iter() {
|
||||
let tp_t = self.get_tp_t(&tp)?;
|
||||
fields.insert(name, tp_t);
|
||||
}
|
||||
Ok(Type::Record(fields))
|
||||
}
|
||||
dict @ TyParam::Dict(_) => Ok(dict_t(dict)),
|
||||
TyParam::BinOp { op, lhs, rhs } => match op {
|
||||
OpKind::Or | OpKind::And => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue