FEATURE: Empty files result in Val::Empty as their result.

We also print a warning message for the consumer.
This commit is contained in:
Jeremy Wall 2019-02-19 15:32:04 -06:00
parent 38e418a1d6
commit 3cfbe6564c

View File

@ -1648,7 +1648,12 @@ impl<'a> FileBuilder<'a> {
Some(importer) => {
let file_contents =
self.get_file_as_string(&def.path.pos, &def.path.fragment)?;
let val = importer.import(file_contents.as_bytes())?;
let val = if file_contents.len() == 0 {
eprintln!("including an empty file. Use NULL as the result");
Rc::new(Val::Empty)
} else {
importer.import(file_contents.as_bytes())?
};
Ok(val)
}
None => Err(Box::new(error::BuildError::new(