mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 12:24:45 +00:00
Merge branch 'main' into py-method-decl
This commit is contained in:
commit
be1c603ba9
5 changed files with 29 additions and 11 deletions
|
@ -269,7 +269,7 @@ impl Context {
|
|||
let op_t = fn1_met(
|
||||
mono_q("Self"),
|
||||
mono_q("R"),
|
||||
option(builtin_mono("Ordering")),
|
||||
or(builtin_mono("Ordering"), NoneType),
|
||||
);
|
||||
let op_t = quant(
|
||||
op_t,
|
||||
|
@ -534,7 +534,7 @@ impl Context {
|
|||
let mut int_partial_ord = Self::builtin_methods("PartialOrd", 2);
|
||||
int_partial_ord.register_builtin_impl(
|
||||
"__partial_cmp__",
|
||||
fn1_met(Int, Int, option(builtin_mono("Ordering"))),
|
||||
fn1_met(Int, Int, or(builtin_mono("Ordering"), NoneType)),
|
||||
Const,
|
||||
Public,
|
||||
);
|
||||
|
@ -1575,7 +1575,7 @@ impl Context {
|
|||
vec![param_t("err_message", Str)],
|
||||
NoneType,
|
||||
);
|
||||
let t_classof = nd_func(vec![param_t("old", Obj)], None, option(Class));
|
||||
let t_classof = nd_func(vec![param_t("old", Obj)], None, Class);
|
||||
let t_compile = nd_func(vec![param_t("src", Str)], None, Code);
|
||||
let t_cond = nd_func(
|
||||
vec![
|
||||
|
@ -1596,7 +1596,7 @@ impl Context {
|
|||
],
|
||||
None,
|
||||
vec![param_t("else", nd_func(vec![], None, mono_q("T")))],
|
||||
option(mono_q("T")),
|
||||
or(mono_q("T"), NoneType),
|
||||
);
|
||||
let t_if = quant(t_if, set! {static_instance("T", Type)});
|
||||
let t_import = nd_func(
|
||||
|
@ -1724,7 +1724,7 @@ impl Context {
|
|||
],
|
||||
None,
|
||||
vec![param_t("else", nd_proc(vec![], None, mono_q("T")))],
|
||||
option(mono_q("T")),
|
||||
or(mono_q("T"), NoneType),
|
||||
);
|
||||
let t_if = quant(t_if, set! {static_instance("T", Type)});
|
||||
let t_for = nd_proc(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use erg_common::vis::Visibility;
|
||||
|
||||
use erg_type::constructors::{builtin_mono, func, option, param_t};
|
||||
use erg_type::constructors::{builtin_mono, func, or, param_t};
|
||||
use erg_type::Type;
|
||||
use Type::*;
|
||||
|
||||
|
@ -24,7 +24,7 @@ impl Context {
|
|||
param_t("family", Int),
|
||||
param_t("type", Int),
|
||||
param_t("proto", Int),
|
||||
param_t("fileno", option(Int)),
|
||||
param_t("fileno", or(Int, NoneType)),
|
||||
],
|
||||
builtin_mono("Socket!"),
|
||||
),
|
||||
|
|
|
@ -454,6 +454,22 @@ impl Context {
|
|||
// TODO: deref_predicate
|
||||
Ok(refinement(refine.var, t, refine.preds))
|
||||
}
|
||||
Type::And(l, r) => {
|
||||
let l = self.deref_tyvar(*l, variance, loc)?;
|
||||
let r = self.deref_tyvar(*r, variance, loc)?;
|
||||
Ok(self.intersection(&l, &r))
|
||||
}
|
||||
Type::Or(l, r) => {
|
||||
let l = self.deref_tyvar(*l, variance, loc)?;
|
||||
let r = self.deref_tyvar(*r, variance, loc)?;
|
||||
Ok(self.union(&l, &r))
|
||||
}
|
||||
Type::Not(l, r) => {
|
||||
let l = self.deref_tyvar(*l, variance, loc)?;
|
||||
let r = self.deref_tyvar(*r, variance, loc)?;
|
||||
// TODO: complement
|
||||
Ok(not(l, r))
|
||||
}
|
||||
t => Ok(t),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue