getting closer ...

This commit is contained in:
2024-02-22 13:47:06 -08:00
parent 7edaf747aa
commit 26bd7e90fd
9 changed files with 137 additions and 65 deletions

View File

@@ -359,19 +359,21 @@ fn generate_random_expression(
.iter()
.filter_map(|(variable, ty)| {
if ty.is_printable() {
Some(variable.clone())
Some((variable.clone(), ty.clone()))
} else {
None
}
})
.collect::<Vec<Variable>>();
.collect::<Vec<_>>();
if possible_variables.is_empty() {
generate_random_binding(rng, env)
} else {
let (variable, var_type) = possible_variables.choose(rng).unwrap();
Expression::Print(
Location::manufactured(),
possible_variables.choose(rng).unwrap().clone(),
ValueOrRef::Ref(Location::manufactured(), var_type.clone(), variable.clone()),
)
}
}