1
0

Break one test with new validation

This commit is contained in:
Jeff 2024-07-11 18:15:03 -04:00
parent 994fa7310b
commit 4ab838509b

View File

@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
use crate::{ use crate::{
context::Context, context::Context,
error::{RuntimeError, ValidationError}, error::{RuntimeError, ValidationError},
identifier::Identifier, identifier::{self, Identifier},
Value, Value,
}; };
@ -111,12 +111,31 @@ impl AbstractNode for ValueNode {
} }
} }
if let Some(Type::Enum { variants, .. }) = context.get_type(&type_name.node)? { if let Some(Type::Enum { name, variants, .. }) = context.get_type(&type_name.node)? {
if variants let mut found = false;
.iter()
.find(|(identifier, _)| identifier == &variant.node) for (identifier, content) in &variants {
.is_none() if identifier == &variant.node {
found = true;
}
if let Some(content) = content {
for r#type in content {
if let Type::Generic {
concrete_type: None,
..
} = r#type
{ {
return Err(ValidationError::FullTypeNotKnown {
identifier: name,
position: variant.position,
});
}
}
}
}
if !found {
return Err(ValidationError::EnumVariantNotFound { return Err(ValidationError::EnumVariantNotFound {
identifier: variant.node.clone(), identifier: variant.node.clone(),
position: variant.position, position: variant.position,