Skip to content

Commit

Permalink
Merge pull request #659 from HigherOrderCO/hvm-net-readback-var-conflict
Browse files Browse the repository at this point in the history
Fix readback when hvm net has `a{n}` or `x{n}` vars
  • Loading branch information
developedby authored Aug 6, 2024
2 parents 5c6eb84 + ddfff57 commit b4a20f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
7 changes: 4 additions & 3 deletions src/net/hvm_to_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
}
Expand All @@ -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 {
Expand Down

0 comments on commit b4a20f1

Please sign in to comment.