summaryrefslogtreecommitdiff
path: root/crates/parser/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/parser/src/lib.rs')
-rw-r--r--crates/parser/src/lib.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index c4f6ff7..c6ae326 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -283,7 +283,25 @@ impl Parser {
continue;
}
- if eof || reader.end_reached {
+ if reader.end_reached {
+ if !buffer.is_empty() {
+ return Err(ParseError::Other("trailing bytes after end of module".into()));
+ }
+
+ if !eof {
+ let read_bytes = Self::read_more(&mut stream, &mut buffer, 1)?;
+ eof = read_bytes == 0;
+
+ if !eof {
+ return Err(ParseError::Other("trailing bytes after end of module".into()));
+ }
+ }
+
+ reader.process_pending_functions(&self.options)?;
+ return reader.into_module(&self.options);
+ }
+
+ if eof {
reader.process_pending_functions(&self.options)?;
return reader.into_module(&self.options);
}