fix: generalization is not performed for some types

This commit is contained in:
Shunsuke Shibayama 2024-05-07 22:31:17 +09:00
parent 58f23493ba
commit fa2c53461d
8 changed files with 248 additions and 91 deletions

View file

@ -102,6 +102,15 @@ impl Context {
)
.quantify();
let t_discard = nd_func(vec![kw(KW_OBJ, Obj)], None, NoneType);
let M = mono_q(TY_M, Constraint::Uninited);
let M = mono_q(TY_M, subtypeof(poly(MUL, vec![ty_tp(M)])));
let Out = M.clone().proj(MOD_OUTPUT);
let t_divmod = nd_func(
vec![kw(KW_A, M.clone()), kw(KW_B, M.clone())],
None,
tuple_t(vec![Out.clone(), Out]),
)
.quantify();
let t_enumerate = no_var_func(
vec![kw(KW_ITERABLE, poly(ITERABLE, vec![ty_tp(T.clone())]))],
vec![kw(KW_START, Int)],
@ -468,6 +477,13 @@ impl Context {
);
self.register_builtin_erg_impl(KW_COND, t_cond, Immutable, vis.clone());
self.register_py_builtin(FUNC_DICT, t_dict, Some(FUNC_DICT), 224);
self.register_builtin_py_impl(
FUNC_DIVMOD,
t_divmod,
Immutable,
vis.clone(),
Some(FUNC_DIVMOD),
);
self.register_builtin_py_impl(
FUNC_ENUMERATE,
t_enumerate,

View file

@ -377,8 +377,9 @@ const CODE_TYPE: &str = "CodeType";
const MODULE_TYPE: &str = "ModuleType";
const FRAME_TYPE: &str = "FrameType";
const FUNC_LIST: &str = "list";
const _FUNC_SET: &str = "set";
const FUNC_SET: &str = "set";
const FUNC_DICT: &str = "dict";
const FUNC_DIVMOD: &str = "divmod";
const FUNC_TUPLE: &str = "tuple";
const UNION: &str = "Union";
const FUNC_STR_ITERATOR: &str = "str_iterator";
@ -506,7 +507,6 @@ const FUNC_POW: &str = "pow";
const FUNC_QUIT: &str = "quit";
const FUNC_REPR: &str = "repr";
const FUNC_ROUND: &str = "round";
const FUNC_SET: &str = "set";
const FUNC_SLICE: &str = "slice";
const FUNC_SORTED: &str = "sorted";
const FUNC_STATICMETHOD: &str = "staticmethod";
@ -707,6 +707,7 @@ const KW_SRC: &str = "src";
const KW_THEN: &str = "then";
const KW_ELSE: &str = "else";
const KW_OBJ: &str = "obj";
const KW_A: &str = "a";
const KW_NAME: &str = "name";
const KW_DEFAULT: &str = "default";
const KW_START: &str = "start";