Skip to content

Commit

Permalink
Update gen_decl.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Jun 17, 2024
1 parent a088185 commit 206c020
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions crates/py2erg/gen_decl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ impl DeclFileGenerator {
.replace('\0', "")
.replace('%', "___");
let ref_t = def.sig.ident().ref_t();
let typ = ref_t.replace_failure().to_string_unabbreviated();
let typ = escape_type(typ);
let typ = escape_type(ref_t.replace_failure().to_string_unabbreviated());
// Erg can automatically import nested modules
// `import http.client` => `http = pyimport "http"`
let decl = if ref_t.is_py_module() {
Expand Down Expand Up @@ -111,7 +110,12 @@ impl DeclFileGenerator {
self.code += &decl;
self.code.push('\n');
if let GenTypeObj::Subclass(class) = &def.obj {
let sup = class.sup.as_ref().typ().to_string_unabbreviated();
let sup = class
.sup
.as_ref()
.typ()
.replace_failure()
.to_string_unabbreviated();
let sup = escape_type(sup);
let decl = format!(".{class_name} <: {sup}\n");
self.code += &decl;
Expand All @@ -122,7 +126,7 @@ impl DeclFileGenerator {
}) = def.obj.base_or_sup()
{
for (attr, t) in rec.iter() {
let typ = escape_type(t.to_string_unabbreviated());
let typ = escape_type(t.replace_failure().to_string_unabbreviated());
let decl = format!("{}.{}: {typ}\n", self.namespace, attr.symbol);
self.code += &decl;
}
Expand All @@ -133,7 +137,7 @@ impl DeclFileGenerator {
}) = def.obj.additional()
{
for (attr, t) in rec.iter() {
let typ = escape_type(t.to_string_unabbreviated());
let typ = escape_type(t.replace_failure().to_string_unabbreviated());
let decl = format!("{}.{}: {typ}\n", self.namespace, attr.symbol);
self.code += &decl;
}
Expand Down

0 comments on commit 206c020

Please sign in to comment.