mirror of
https://github.com/Dummi26/mers.git
synced 2025-12-13 19:06:16 +01:00
add function type annotation (Input1 -> Output1, Input2 -> Output2)
This commit is contained in:
@@ -36,7 +36,7 @@ impl Config {
|
||||
let func = &t.0[1];
|
||||
for func_t in func.types.iter() {
|
||||
if let Some(f) = func_t.as_any().downcast_ref::<data::function::FunctionT>() {
|
||||
match (f.0)(&arg) {
|
||||
match f.o(&arg) {
|
||||
Ok(out) => {
|
||||
if !out.is_included_in(&arg) {
|
||||
return Err(format!("Function returns a value of type {out}, which isn't included in the type of the reference, {arg}.").into());
|
||||
@@ -150,7 +150,7 @@ impl Config {
|
||||
} else { [v].into_iter().collect() }
|
||||
} else { [v].into_iter().collect() }) {
|
||||
if let Some(t) = t.as_any().downcast_ref::<data::function::FunctionT>() {
|
||||
for t in (t.0)(&Type::empty_tuple())?.types {
|
||||
for t in t.o(&Type::empty_tuple())?.types {
|
||||
if let Some(t) = t.as_any().downcast_ref::<data::tuple::TupleT>() {
|
||||
if t.0.len() > 1 {
|
||||
return Err(format!("called loop with funcion that might return a tuple of length > 1").into());
|
||||
@@ -293,7 +293,7 @@ fn get_try(allow_unused_functions: bool) -> Data {
|
||||
if !skip_checks {
|
||||
func_errors.push((
|
||||
fvi,
|
||||
match ft.0(&arg_type) {
|
||||
match ft.o(&arg_type) {
|
||||
Err(e) => {
|
||||
func_fallible = true;
|
||||
if let Some(errs) =
|
||||
|
||||
@@ -53,7 +53,7 @@ impl Config {
|
||||
.collect::<Option<Vec<_>>>(),
|
||||
) {
|
||||
for f in f {
|
||||
let _ret = f.0(&iter)?;
|
||||
let _ret = f.o(&iter)?;
|
||||
// if !ret.is_zero_tuple() {
|
||||
// return Err(format!("for_each function must return (), not {ret}").into());
|
||||
// }
|
||||
@@ -325,9 +325,9 @@ impl MersData for Iter {
|
||||
impl IterT {
|
||||
pub fn new(iter: ItersT, data: Type) -> Result<Self, CheckError> {
|
||||
let t = match &iter {
|
||||
ItersT::Map(f) => (f.0)(&data)?,
|
||||
ItersT::Map(f) => f.o(&data)?,
|
||||
ItersT::Filter(f) => {
|
||||
if (f.0)(&data)?.is_included_in(&data::bool::BoolT) {
|
||||
if f.o(&data)?.is_included_in(&data::bool::BoolT) {
|
||||
data.clone()
|
||||
} else {
|
||||
return Err(format!(
|
||||
@@ -337,7 +337,7 @@ impl IterT {
|
||||
}
|
||||
}
|
||||
ItersT::FilterMap(f) => {
|
||||
if let Some(v) = (f.0)(&data)?.one_tuple_possible_content() {
|
||||
if let Some(v) = f.o(&data)?.one_tuple_possible_content() {
|
||||
v
|
||||
} else {
|
||||
return Err(
|
||||
@@ -346,7 +346,7 @@ impl IterT {
|
||||
}
|
||||
}
|
||||
ItersT::MapWhile(f) => {
|
||||
if let Some(t) = (f.0)(&data)?.one_tuple_possible_content() {
|
||||
if let Some(t) = f.o(&data)?.one_tuple_possible_content() {
|
||||
t
|
||||
} else {
|
||||
return Err(
|
||||
|
||||
@@ -36,7 +36,7 @@ impl Config {
|
||||
let mut out = Type::empty();
|
||||
for t in a.types.iter() {
|
||||
if let Some(f) = t.as_any().downcast_ref::<data::function::FunctionT>() {
|
||||
match (f.0)(&Type::empty_tuple()) {
|
||||
match f.o(&Type::empty_tuple()) {
|
||||
Ok(t) => out.add(Arc::new(t)),
|
||||
Err(e) => return Err(CheckError::new().msg(format!("Can't call thread on a function which can't be called on an empty tuple: ")).err(e))
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ impl MersStatement for Chain {
|
||||
.as_any()
|
||||
.downcast_ref::<crate::data::function::FunctionT>()
|
||||
{
|
||||
match (func.0)(&arg) {
|
||||
match func.o(&arg) {
|
||||
Ok(t) => o.add(Arc::new(t)),
|
||||
Err(e) => {
|
||||
return Err(if let Some(_) = &self.as_part_of_include {
|
||||
|
||||
Reference in New Issue
Block a user