Skip to content

Commit

Permalink
Fix: avoid node overriding and re-instantiate a same function (#198)
Browse files Browse the repository at this point in the history
* fix: avoid re-instantiate functions/methods

* fix: monomorphized expr shouldn't override existing nodes

* fix: refactor function instantiation and always check the resolved qualified name
  • Loading branch information
katat authored Oct 17, 2024
1 parent 19dedf6 commit c223380
Show file tree
Hide file tree
Showing 3 changed files with 249 additions and 158 deletions.
13 changes: 4 additions & 9 deletions src/mast/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@ use super::MastCtx;
impl Expr {
/// Convert an expression to another expression, with the same span and a regenerated node id.
pub fn to_mast<B: Backend>(&self, ctx: &mut MastCtx<B>, kind: &ExprKind) -> Expr {
match ctx.generic_func_scope {
// not in any generic function scope
Some(0) => self.clone(),
// in a generic function scope
_ => Expr {
node_id: ctx.next_node_id(),
kind: kind.clone(),
..self.clone()
},
Expr {
node_id: ctx.next_node_id(),
kind: kind.clone(),
..self.clone()
}
}
}
Loading

0 comments on commit c223380

Please sign in to comment.