Skip to content

Commit 771b2bd

Browse files
authored
Fix newline separators between invalid end instructions (#1640)
This commit fixes a bug from a prior refactoring where when there were too many `end` instructions in a function, which is invalid, then printing would confusingly "fuse" instructions together by not printing a separator.
1 parent 3f4960a commit 771b2bd

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

crates/wasmprinter/src/operator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ impl<'printer, 'state, 'a, 'b> PrintOperator<'printer, 'state, 'a, 'b> {
7171
fn block_end(&mut self) -> Result<()> {
7272
if self.printer.nesting > self.nesting_start {
7373
self.printer.nesting -= 1;
74-
self.separator()?;
7574
}
75+
self.separator()?;
7676
Ok(())
7777
}
7878

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
(module
22
(type (;0;) (func))
3-
(func (;0;) (type 0)end)
3+
(func (;0;) (type 0)
4+
end
5+
)
46
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
;; RUN: print %
2+
3+
(module
4+
(func end i32.const 0 drop end)
5+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(module
2+
(type (;0;) (func))
3+
(func (;0;) (type 0)
4+
end
5+
i32.const 0
6+
drop
7+
end
8+
)
9+
)

0 commit comments

Comments
 (0)