Parse sources of conditional env modules.

Do nothing about it yet, but trigger an error if env/default.ak is
  missing; but only if there's any module at all under env.
This commit is contained in:
KtorZ
2024-08-03 17:42:55 +02:00
parent 4645257e62
commit c9d0da0c22
4 changed files with 42 additions and 2 deletions

View File

@@ -28,6 +28,7 @@ pub type UntypedModule = Module<(), UntypedDefinition>;
pub enum ModuleKind {
Lib,
Validator,
Env,
}
impl ModuleKind {
@@ -38,6 +39,10 @@ impl ModuleKind {
pub fn is_lib(&self) -> bool {
matches!(self, ModuleKind::Lib)
}
pub fn is_env(&self) -> bool {
matches!(self, ModuleKind::Env)
}
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]

View File

@@ -785,7 +785,9 @@ impl<'a> Environment<'a> {
})?;
if module_info.kind.is_validator()
&& (self.current_kind.is_lib() || !self.current_module.starts_with("tests"))
&& (self.current_kind.is_lib()
|| self.current_kind.is_env()
|| !self.current_module.starts_with("tests"))
{
return Err(Error::ValidatorImported {
location: *location,