fix: aliasing bug

This commit is contained in:
Shunsuke Shibayama 2023-03-12 12:17:47 +09:00
parent d3678b1780
commit fb26d6d80e
2 changed files with 11 additions and 4 deletions

View file

@ -252,6 +252,13 @@ impl Context {
self.erg_to_py_names
.insert(ident.inspect().clone(), py_name.clone());
}
let ident = if cfg!(feature = "py_compatible") && py_name.is_some() {
let mut symbol = ident.name.clone().into_token();
symbol.content = py_name.clone().unwrap();
Identifier::new(ident.vis.clone(), VarName::new(symbol))
} else {
ident.clone()
};
let vis = self.instantiate_vis_modifier(&ident.vis)?;
// already defined as const
if sig.is_const() {

View file

@ -69,7 +69,7 @@ impl ASTLowerer {
} else {
self.module
.context
.assign_var_sig(&sig, found_body_t, id, py_name.clone())?;
.assign_var_sig(&sig, found_body_t, id, None)?;
}
// FIXME: Identifier::new should be used
let mut ident = hir::Identifier::bare(ident.clone());
@ -551,7 +551,7 @@ impl ASTLowerer {
};
self.module.context.decls.insert(name, vi);
}
let ident = if cfg!(feature = "py_compatible") {
let new_ident = if cfg!(feature = "py_compatible") {
let mut symbol = ident.name.clone().into_token();
symbol.content = py_name.clone();
Identifier::new(ident.vis.clone(), VarName::new(symbol))
@ -571,7 +571,7 @@ impl ASTLowerer {
Some(TypeObj::Builtin(Type::Uninited)),
None,
);
self.module.context.register_gen_type(&ident, ty_obj)?;
self.module.context.register_gen_type(&new_ident, ty_obj)?;
}
Type::TraitType => {
let ty_obj = GenTypeObj::trait_(
@ -579,7 +579,7 @@ impl ASTLowerer {
TypeObj::Builtin(Type::Uninited),
None,
);
self.module.context.register_gen_type(&ident, ty_obj)?;
self.module.context.register_gen_type(&new_ident, ty_obj)?;
}
_ => {}
}