Fix polymorphic type infering bugs

Delete: DefaultParamSignarure
Add: some convinient APIs (py, p!)

Inferences can now be made that take into account the variance of polymorphic types
This commit is contained in:
Shunsuke Shibayama 2022-08-14 00:45:55 +09:00
parent b634be1c80
commit 30f6e98715
12 changed files with 552 additions and 728 deletions

View file

@ -44,6 +44,7 @@ fn convert_to_python_attr(class: &str, uniq_obj_name: Option<&str>, name: Str) -
("Complex" | "Real" | "Int" | "Nat" | "Float", _, "Real") => Str::ever("real"),
("Complex" | "Real" | "Int" | "Nat" | "Float", _, "Imag") => Str::ever("imag"),
("Module", Some("random"), "randint!") => Str::ever("randint"),
("Module", Some("random"), "choice!") => Str::ever("choice"),
_ => name,
}
}
@ -68,8 +69,8 @@ fn convert_to_python_name(name: Str) -> Str {
"import" => Str::ever("__import__"),
"input!" => Str::ever("input"),
"log" => Str::ever("print"), // TODO: log != print (prints after executing)
"print!" => Str::ever("print"),
"pyimport" => Str::ever("__import__"),
"p!" | "print!" => Str::ever("print"),
"py" | "pyimport" => Str::ever("__import__"),
"quit" | "exit" => Str::ever("quit"),
_ => name,
}