Fix incongruous panic when annotation is missing from Datum.
It's fine for the argument to not be annotated; in which case we simply default back to an `Option<Data>`.
This commit is contained in:
parent
4003343444
commit
d615b4f889
|
@ -140,8 +140,10 @@ impl Validator {
|
||||||
.map(|datum| {
|
.map(|datum| {
|
||||||
match datum.tipo.as_ref() {
|
match datum.tipo.as_ref() {
|
||||||
Type::App { module: module_name, name, args, .. } if module_name.is_empty() && name == well_known::OPTION => {
|
Type::App { module: module_name, name, args, .. } if module_name.is_empty() && name == well_known::OPTION => {
|
||||||
let Some(Annotation::Constructor { arguments, .. }) = datum.annotation.as_ref() else {
|
let annotation = if let Some(Annotation::Constructor { arguments, .. }) = datum.annotation.as_ref() {
|
||||||
panic!("Datum isn't an option but should be; this should have been caught by the type-checker!");
|
arguments.first().cloned().expect("Datum isn't an option but should be; this should have been caught by the type-checker!")
|
||||||
|
} else {
|
||||||
|
Annotation::data(datum.location)
|
||||||
};
|
};
|
||||||
|
|
||||||
Annotated::from_type(
|
Annotated::from_type(
|
||||||
|
@ -149,7 +151,7 @@ impl Validator {
|
||||||
tipo_or_annotation(module, &TypedArg {
|
tipo_or_annotation(module, &TypedArg {
|
||||||
arg_name: datum.arg_name.clone(),
|
arg_name: datum.arg_name.clone(),
|
||||||
location: datum.location,
|
location: datum.location,
|
||||||
annotation: arguments.first().cloned(),
|
annotation: Some(annotation),
|
||||||
doc: datum.doc.clone(),
|
doc: datum.doc.clone(),
|
||||||
is_validator_param: datum.is_validator_param,
|
is_validator_param: datum.is_validator_param,
|
||||||
tipo: args.first().expect("Option always have a single type argument.").clone()
|
tipo: args.first().expect("Option always have a single type argument.").clone()
|
||||||
|
|
Loading…
Reference in New Issue