Allow Fuzzer with type parameter

Also fix shrinker first reduction, as well as passing of List/Tuples to fuzzer.
This commit is contained in:
KtorZ
2024-02-27 09:50:33 +01:00
parent c29d163900
commit c766f44601
5 changed files with 101 additions and 79 deletions

View File

@@ -1181,7 +1181,7 @@ pub fn find_list_clause_or_default_first(clauses: &[TypedClause]) -> &TypedClaus
.unwrap_or(&clauses[0])
}
pub fn convert_data_to_type(term: Term<Name>, field_type: &Rc<Type>) -> Term<Name> {
pub fn convert_data_to_type(term: Term<Name>, field_type: &Type) -> Term<Name> {
if field_type.is_int() {
Term::un_i_data().apply(term)
} else if field_type.is_bytearray() {
@@ -1222,7 +1222,7 @@ pub fn convert_data_to_type(term: Term<Name>, field_type: &Rc<Type>) -> Term<Nam
pub fn convert_data_to_type_debug(
term: Term<Name>,
field_type: &Rc<Type>,
field_type: &Type,
error_term: Term<Name>,
) -> Term<Name> {
if field_type.is_int() {

View File

@@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::{collections::HashMap, ops::Deref, rc::Rc};
use crate::{
ast::{
@@ -11,10 +11,9 @@ use crate::{
builtins::function,
expr::{TypedExpr, UntypedExpr},
line_numbers::LineNumbers,
tipo::{Span, Type},
tipo::{Span, Type, TypeVar},
IdGenerator,
};
use std::rc::Rc;
use super::{
environment::{generalise, EntityKind, Environment},
@@ -391,8 +390,16 @@ fn infer_definition(
location: *location,
})
}
Type::Fn { .. } | Type::Var { .. } => {
todo!("Fuzzer contains functions and/or non-concrete data-types?");
Type::Var { tipo } => match tipo.borrow().deref() {
TypeVar::Link { tipo } => tipo_to_annotation(tipo, location),
_ => todo!(
"Fuzzer contains functions and/or non-concrete data-types? {tipo:#?}"
),
},
Type::Fn { .. } => {
todo!(
"Fuzzer contains functions and/or non-concrete data-types? {tipo:#?}"
);
}
}
}