Add test; Pass test by fixing type validation bug
This commit is contained in:
parent
85419c47be
commit
a23688803c
@ -57,25 +57,18 @@ impl AbstractTree for As {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Type::Any => {
|
Type::Any => {
|
||||||
// Do no validation when converting from "any" to a list.
|
// Do no validation when converting from "any" to a list.
|
||||||
// This effectively defers to runtime behavior, potentially
|
// This effectively defers to runtime behavior, potentially
|
||||||
// causing a runtime error.
|
// causing a runtime error.
|
||||||
}
|
}
|
||||||
Type::Boolean => todo!(),
|
_ => {
|
||||||
Type::Collection => todo!(),
|
return Err(ValidationError::ConversionImpossible {
|
||||||
Type::Custom(_) => todo!(),
|
initial_type,
|
||||||
Type::Float => todo!(),
|
target_type: self.r#type.clone(),
|
||||||
Type::Function {
|
})
|
||||||
parameter_types: _,
|
}
|
||||||
return_type: _,
|
|
||||||
} => todo!(),
|
|
||||||
Type::Integer => todo!(),
|
|
||||||
Type::Map(_) => todo!(),
|
|
||||||
Type::None => todo!(),
|
|
||||||
Type::Number => todo!(),
|
|
||||||
Type::Range => todo!(),
|
|
||||||
Type::Option(_) => todo!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,15 @@ impl AbstractTree for FunctionCall {
|
|||||||
Ok(value_type)
|
Ok(value_type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FunctionExpression::Index(index) => index.expected_type(context),
|
FunctionExpression::Index(index) => {
|
||||||
|
let index_type = index.expected_type(context)?;
|
||||||
|
|
||||||
|
if let Type::Function { return_type, .. } = index_type {
|
||||||
|
Ok(*return_type)
|
||||||
|
} else {
|
||||||
|
Ok(index_type)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ fn conversion_runtime_error() {
|
|||||||
interpret(&format!("json:parse('{JSON}') as [map]")),
|
interpret(&format!("json:parse('{JSON}') as [map]")),
|
||||||
Err(Error::Runtime(RuntimeError::ConversionImpossible {
|
Err(Error::Runtime(RuntimeError::ConversionImpossible {
|
||||||
value: json_value,
|
value: json_value,
|
||||||
target_type: Type::List(Box::new(Type::Float))
|
target_type: Type::List(Box::new(Type::Map(None)))
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user