Skip to content

Commit

Permalink
fixed it a bit cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
michele-nuzzi committed May 18, 2024
1 parent 7273ea3 commit e7e8b9d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
18 changes: 11 additions & 7 deletions packages/onchain/src/IR/IRNodes/IRLetted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,13 +562,17 @@ export function getNormalizedLettedArgs( lettedDbn: number, value: IRTerm ): [ n
else return false; // modified parent
}
else {
// inline
_modifyChildFromTo(
node.parent,
node,
node.value
);
return true; // modified parent
if( node.parent ) // only modify if not root
{
// inline
_modifyChildFromTo(
node.parent,
node,
node.value
);
return true; // modified parent
}
else return false;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ export function _modifyChildFromTo( parent: IRParentTerm | undefined, currentChi
{
if( parent === undefined )
{
if( isIRTerm( currentChild ) )
parent = currentChild.parent as IRParentTerm;
else throw new Error(
"'_modifyChildFromTo' received an undefined parent"
throw new Error(
"'_modifyChildFromTo' received an undefined parent, possibly root"
);
}
if(
Expand Down

0 comments on commit e7e8b9d

Please sign in to comment.