Fix readback when hvm net has a{n} or x{n} vars

This commit is contained in:
Nicolas Abril 2024-08-06 14:00:09 +02:00
parent 5c6eb841e4
commit ddfff57b91
2 changed files with 6 additions and 3 deletions

View File

@ -14,6 +14,7 @@ and this project does not currently adhere to a particular versioning scheme.
- Fix local definitions not being desugared properly. ([#623][gh-623])
- Expand references to functions generated by the `float_combinators` pass inside the main function. ([#642][gh-642])
- Expand references inside constructors in the main function. ([#643][gh-643])
- Fix readback when hvm net has `a{n}` or `x{n}` vars. ([#659][gh-659])
### Added
@ -416,4 +417,5 @@ and this project does not currently adhere to a particular versioning scheme.
[gh-642]: https://github.com/HigherOrderCO/Bend/issues/642
[gh-643]: https://github.com/HigherOrderCO/Bend/issues/643
[gh-648]: https://github.com/HigherOrderCO/Bend/issues/648
[gh-659]: https://github.com/HigherOrderCO/Bend/pull/659
[Unreleased]: https://github.com/HigherOrderCO/Bend/compare/0.2.36...HEAD

View File

@ -23,7 +23,8 @@ fn hvm_to_inodes(net: &Net) -> INodes {
// Convert all the trees forming active pairs.
for (i, (_, tree1, tree2)) in net.rbag.iter().enumerate() {
let tree_root = format!("a{i}");
// This name cannot appear anywhere in the original net
let tree_root = format!("%a{i}");
let mut tree1 = tree_to_inodes(tree1, tree_root.clone(), net_root, &mut n_vars);
inodes.append(&mut tree1);
let mut tree2 = tree_to_inodes(tree2, tree_root, net_root, &mut n_vars);
@ -33,7 +34,8 @@ fn hvm_to_inodes(net: &Net) -> INodes {
}
fn new_var(n_vars: &mut NodeId) -> String {
let new_var = format!("x{n_vars}");
// This name cannot appear anywhere in the original net
let new_var = format!("%x{n_vars}");
*n_vars += 1;
new_var
}
@ -46,7 +48,6 @@ fn tree_to_inodes(tree: &Tree, tree_root: String, net_root: &str, n_vars: &mut N
n_vars: &mut NodeId,
) -> String {
if let Tree::Var { nam } = subtree {
//
if nam == net_root {
"_".to_string()
} else {