mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 20:34:44 +00:00
Add notin
operator
This commit is contained in:
parent
5342edcf4d
commit
76bf5fa44c
2 changed files with 6 additions and 1 deletions
|
@ -2173,7 +2173,8 @@ impl Context {
|
||||||
let T = mono_q("T", instanceof(Type));
|
let T = mono_q("T", instanceof(Type));
|
||||||
let I = mono_q("I", subtypeof(poly("In", vec![ty_tp(T.clone())])));
|
let I = mono_q("I", subtypeof(poly("In", vec![ty_tp(T.clone())])));
|
||||||
let op_t = bin_op(I, T, Bool).quantify();
|
let op_t = bin_op(I, T, Bool).quantify();
|
||||||
self.register_builtin_impl("__in__", op_t, Const, Private);
|
self.register_builtin_impl("__in__", op_t.clone(), Const, Private);
|
||||||
|
self.register_builtin_impl("__notin__", op_t, Const, Private);
|
||||||
/* unary */
|
/* unary */
|
||||||
// TODO: Boolの+/-は警告を出したい
|
// TODO: Boolの+/-は警告を出したい
|
||||||
let M = mono_q("M", subtypeof(mono("Mutizable")));
|
let M = mono_q("M", subtypeof(mono("Mutizable")));
|
||||||
|
|
|
@ -39,6 +39,7 @@ pub fn binop_to_dname(op: &str) -> &str {
|
||||||
"//" => "__floordiv__",
|
"//" => "__floordiv__",
|
||||||
"**" => "__pow__",
|
"**" => "__pow__",
|
||||||
"%" => "__mod__",
|
"%" => "__mod__",
|
||||||
|
"@" => "__matmul__",
|
||||||
".." => "__rng__",
|
".." => "__rng__",
|
||||||
"<.." => "__lorng__",
|
"<.." => "__lorng__",
|
||||||
"..<" => "__rorng__",
|
"..<" => "__rorng__",
|
||||||
|
@ -47,6 +48,7 @@ pub fn binop_to_dname(op: &str) -> &str {
|
||||||
"||" | "or" => "__or__",
|
"||" | "or" => "__or__",
|
||||||
"^^" => "__xor__",
|
"^^" => "__xor__",
|
||||||
"in" => "__in__",
|
"in" => "__in__",
|
||||||
|
"notin" => "__notin__", // NOTE: this doesn't exist in Python
|
||||||
"contains" => "__contains__",
|
"contains" => "__contains__",
|
||||||
"subof" => "__subof__",
|
"subof" => "__subof__",
|
||||||
"supof" => "__supof__",
|
"supof" => "__supof__",
|
||||||
|
@ -82,6 +84,7 @@ pub fn readable_name(name: &str) -> &str {
|
||||||
"__floordiv__" => "`//`",
|
"__floordiv__" => "`//`",
|
||||||
"__pow__" => "`**`",
|
"__pow__" => "`**`",
|
||||||
"__mod__" => "`%`",
|
"__mod__" => "`%`",
|
||||||
|
"__matmul__" => "`@`",
|
||||||
"__rng__" => "`..`",
|
"__rng__" => "`..`",
|
||||||
"__lorng__" => "`<..`",
|
"__lorng__" => "`<..`",
|
||||||
"__rorng__" => "`..<`",
|
"__rorng__" => "`..<`",
|
||||||
|
@ -89,6 +92,7 @@ pub fn readable_name(name: &str) -> &str {
|
||||||
"__and__" => "`and`",
|
"__and__" => "`and`",
|
||||||
"__or__" => "`or`",
|
"__or__" => "`or`",
|
||||||
"__in__" => "`in`",
|
"__in__" => "`in`",
|
||||||
|
"__notin__" => "`notin`",
|
||||||
"__contains__" => "`contains`",
|
"__contains__" => "`contains`",
|
||||||
"__subof__" => "`subof`",
|
"__subof__" => "`subof`",
|
||||||
"__supof__" => "`supof`",
|
"__supof__" => "`supof`",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue