Skip to content

Commit

Permalink
Merge branch 'main' into enricozb/print-num
Browse files Browse the repository at this point in the history
  • Loading branch information
enricozb committed May 29, 2024
2 parents 0049fb3 + c8f85a3 commit 73dd755
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
Binary file modified paper/PAPER.pdf
Binary file not shown.
27 changes: 13 additions & 14 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ impl Net {
pub fn show(&self) -> String {
let mut s = self.root.show();
for (par, fst, snd) in &self.rbag {
s.push_str(" & ");
s.push_str(if *par { "!" } else { "" });
s.push_str(" &");
s.push_str(if *par { "!" } else { " " });
s.push_str(&fst.show());
s.push_str(" ~ ");
s.push_str(&snd.show());
Expand Down Expand Up @@ -505,18 +505,17 @@ impl Book {
}
let mut book = hvm::Book { defs: Vec::new() };
for (fid, name) in &fid_to_name {
if let Some(ast_def) = self.defs.get(name) {
let mut def = hvm::Def {
name: name.clone(),
safe: true,
root: hvm::Port(0),
rbag: vec![],
node: vec![],
vars: 0,
};
ast_def.build(&mut def, &name_to_fid, &mut BTreeMap::new());
book.defs.push(def);
}
let ast_def = self.defs.get(name).expect("missing `@main` definition");
let mut def = hvm::Def {
name: name.clone(),
safe: true,
root: hvm::Port(0),
rbag: vec![],
node: vec![],
vars: 0,
};
ast_def.build(&mut def, &name_to_fid, &mut BTreeMap::new());
book.defs.push(def);
}
return book;
}
Expand Down
Empty file added tests/programs/empty.hvm
Empty file.
2 changes: 1 addition & 1 deletion tests/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn execute_hvm(args: &[&OsStr]) -> Result<String, Box<dyn Error>> {
stderr.read_to_string(&mut output)?;

Ok(if !status.success() {
format!("exited with code {status}:\n{output}")
format!("{status}\n{output}")
} else {
parse_output(&output).unwrap_or_else(|err| {
panic!("error parsing output:\n{err}\n\n{output}")
Expand Down
9 changes: 9 additions & 0 deletions tests/snapshots/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: tests/run.rs
expression: rust_output
input_file: tests/programs/empty.hvm
---
exit status: 101
thread 'main' panicked at src/ast.rs:508:41:
missing `@main` definition
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

0 comments on commit 73dd755

Please sign in to comment.