From 681e6e36d818d6518461b5481a226ed8b638be14 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Thu, 19 Nov 2026 01:18:55 -0500 Subject: [PATCH 1/2] Count an argument's expected type when it's what the call's solution has to be An argument's expected type that references the callee's generics isn't a hint when the call's own expected type is a type of its own and no argument still to be compiled can add to those generics: the call's solution has to fit it then, and a narrower solution for the argument only narrows the call's, which its expected type then still holds. So `wrap(map(fn(x) => x, 5))` with `(5, Int)` expected compiles, as `wrap::<5>(map::<5, 5>(...))` does. --- .../src/compile/expr/call_inference.rs | 22 +++++++++- ...eneric_inference_lambda_parameter_vars.rue | 12 ++++++ ...neric_inference_lambda_parameter_vars.yaml | 7 ++++ ...inference_lambda_parameter_vars_errors.rue | 10 +++-- ...nference_lambda_parameter_vars_errors.yaml | 41 ++++++++++--------- 5 files changed, 67 insertions(+), 25 deletions(-) diff --git a/crates/rue-compiler/src/compile/expr/call_inference.rs b/crates/rue-compiler/src/compile/expr/call_inference.rs index 29f1c753..ac6a0087 100644 --- a/crates/rue-compiler/src/compile/expr/call_inference.rs +++ b/crates/rue-compiler/src/compile/expr/call_inference.rs @@ -71,6 +71,9 @@ pub(crate) fn infer_call( // only uses the type expected of it for the generics its arguments don't give a type (see // `refine_element_expected`), so it isn't solved again for it either let fallback_only = ctx.is_expected_type_fallback() && !args.is_empty(); + // Whether the type expected of the call is a type of its own, which it has to be assignable to + let expected_is_final = expected_type.is_some() && !ctx.is_expected_type_hint(); + let solver = ctx.call_solver(expected); let solver = Rc::new(if fallback_only { solver.fallback_only() @@ -140,11 +143,15 @@ pub(crate) fn infer_call( })); // The parameter's type is only a hint while it references the callee's generics, since - // what they're inferred as so far can still widen + // what they're inferred as so far can still widen. Unless the call's own expected type is + // a type of its own and no argument still to be compiled can add to them: then it's what + // the call's solution will have to be, so `wrap(map(fn(x) => x, 5))` with `(5, Int)` + // expected solves `map` for `5` let hint = function .generics .iter() - .any(|&generic| contains_generic(ctx.types_mut(), param, generic)); + .any(|&generic| contains_generic(ctx.types_mut(), param, generic)) + && !(expected_is_final && order.settles(i)); // A lambda expected to be exactly the parameter's function type wraps the callee's // generics in its parameters (see `ParameterWrap`) @@ -741,6 +748,17 @@ impl ArgumentOrder { argument.is_lambda() && self.last_settled && !argument.returns_reads() } + /// Whether no argument still to be compiled, other than this one, can add to the generics in + /// its parameter type. + fn settles(&self, i: usize) -> bool { + let writes = &self.arguments[i].writes; + + self.pending + .iter() + .filter(|&&other| other != i) + .all(|&other| self.arguments[other].writes.is_disjoint(writes)) + } + /// Whether every argument has been compiled. fn is_done(&self) -> bool { self.pending.is_empty() diff --git a/tests/types/generic_inference_lambda_parameter_vars.rue b/tests/types/generic_inference_lambda_parameter_vars.rue index 802cc72f..a5c3c84c 100644 --- a/tests/types/generic_inference_lambda_parameter_vars.rue +++ b/tests/types/generic_inference_lambda_parameter_vars.rue @@ -179,3 +179,15 @@ test fn excluded_generic_next_to_a_wrapped_one() -> Int { let result: (5, Int) = mixed_map(fn(p, callback) => (p.first, p.rest + callback(p.rest)), 5, 6); result.first + result.rest } + +fn wrap(value: T) -> (T, Int) { + (value, 1) +} + +test fn argument_of_a_call_with_a_final_expected_type() -> Int { + // `wrap`'s `(5, Int)` is a type of its own, and no other argument can add to its `T`, so the + // `5` its argument is expected to be is what `T` has to be, and `map` is solved for it, as + // `wrap::<5>(map::<5, 5>(...))` is + let result: (5, Int) = wrap(map(fn(x) => x, 5)); + result.first +} diff --git a/tests/types/generic_inference_lambda_parameter_vars.yaml b/tests/types/generic_inference_lambda_parameter_vars.yaml index f7de2a5d..ecb0e4b3 100644 --- a/tests/types/generic_inference_lambda_parameter_vars.yaml +++ b/tests/types/generic_inference_lambda_parameter_vars.yaml @@ -125,6 +125,13 @@ tests: runtime_cost: 2605 byte_cost: 852000 total_cost: 854605 +- name: argument_of_a_call_with_a_final_expected_type + program: (a (q . 2) (q 5)) + debug_program: (a (q 2 (q 5 2) (c (a 6 (a 4 (c (c (q . 2) (c (c (q . 1) (q . 2)) (c (q . 1) ()))) (q . 5)))) 1)) (c (c (q 2 2 (c 3 ())) (q 4 1 (q . 1))) ())) + output: "5" + runtime_cost: 179 + byte_cost: 156000 + total_cost: 156179 diagnostics: - |- Binding `result` is returned directly after it's declared at generic_inference_lambda_parameter_vars.rue:61:5 diff --git a/tests/types/generic_inference_lambda_parameter_vars_errors.rue b/tests/types/generic_inference_lambda_parameter_vars_errors.rue index df3b59a9..61813fb6 100644 --- a/tests/types/generic_inference_lambda_parameter_vars_errors.rue +++ b/tests/types/generic_inference_lambda_parameter_vars_errors.rue @@ -9,6 +9,10 @@ fn wrap(value: T) -> (T, Int) { (value, 1) } +fn wrap_with(_first: T, value: T) -> (T, Int) { + (value, 1) +} + fn map_spread(function: fn(...a: A) -> B, value: A) -> B { function(...value) } @@ -89,9 +93,9 @@ fn main() -> Int { // The lambda returns `x + 0`, not `x`, so the expected bound doesn't reach `x` let computed: 5 = map(fn(x) => x + 0, 5); - // A call that's an argument of an enclosing call is only expected to be what that call has - // inferred so far, which it can still widen, so it isn't solved again for it - let nested: (5, Int) = wrap(map(fn(x) => x, 5)); + // `wrap_with`'s `T` has to hold the `1` too, so no instantiation gives `(5, Int)`, and `map` is + // solved as before + let nested: (5, Int) = wrap_with(1, map(fn(x) => x, 5)); // `x` would have to be `6`, which `5` isn't, so the call is left as it was and reports `Int` let unfitting: 6 = map(fn(x) => x, 5); diff --git a/tests/types/generic_inference_lambda_parameter_vars_errors.yaml b/tests/types/generic_inference_lambda_parameter_vars_errors.yaml index 69480e69..eff6ffcc 100644 --- a/tests/types/generic_inference_lambda_parameter_vars_errors.yaml +++ b/tests/types/generic_inference_lambda_parameter_vars_errors.yaml @@ -1,21 +1,22 @@ diagnostics: -- Unused function `apply_to` at generic_inference_lambda_parameter_vars_errors.rue:16:4 -- "Cannot assign `(fn(x: T) -> T | Int, \"hi\")` to `(fn(value: T | Int | String) -> T | Int | String, T | Int | String)`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:25:14" -- "Cannot assign `(fn(y: T) -> T, 1)` to `(fn(value: T | Int) -> T | Int, T | Int)`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:26:27" -- Condition always evaluates to `false` at generic_inference_lambda_parameter_vars_errors.rue:27:25 -- Unused function `call_back` at generic_inference_lambda_parameter_vars_errors.rue:38:4 -- Unused function `five_only` at generic_inference_lambda_parameter_vars_errors.rue:44:4 -- "Cannot assign `(fn(y: T, _other: fn(v: T) -> Int) -> Int, (7, fn(_z: Int) -> 0))` to `(fn(value: Int, callback: fn(v: Int) -> Int) -> Int, (Int, fn(v: Int) -> Int))`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:53:39" -- Unused function `callback_map` at generic_inference_lambda_parameter_vars_errors.rue:66:4 -- Binding `result` is returned directly after it's declared at generic_inference_lambda_parameter_vars_errors.rue:74:5 -- Cannot compare `Int` to `7` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:74:21 -- Cannot infer generic `U` for `make`; specify it explicitly, e.g. `make::<...>()` at generic_inference_lambda_parameter_vars_errors.rue:87:32 -- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:90:23 -- Cannot compare `(Int, Int)` to `(5, Int)` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:94:28 -- Cannot compare `Int` to `6` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:97:24 -- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:100:21 -- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:101:22 -- Unused generic type `T` at generic_inference_lambda_parameter_vars_errors.rue:101:29 -- Cannot assign `(Int, 1)` to `(5, 2)`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:105:30 -- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:108:16 -- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:112:19 +- Unused function `wrap` at generic_inference_lambda_parameter_vars_errors.rue:8:4 +- Unused function `apply_to` at generic_inference_lambda_parameter_vars_errors.rue:20:4 +- "Cannot assign `(fn(x: T) -> T | Int, \"hi\")` to `(fn(value: T | Int | String) -> T | Int | String, T | Int | String)`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:29:14" +- "Cannot assign `(fn(y: T) -> T, 1)` to `(fn(value: T | Int) -> T | Int, T | Int)`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:30:27" +- Condition always evaluates to `false` at generic_inference_lambda_parameter_vars_errors.rue:31:25 +- Unused function `call_back` at generic_inference_lambda_parameter_vars_errors.rue:42:4 +- Unused function `five_only` at generic_inference_lambda_parameter_vars_errors.rue:48:4 +- "Cannot assign `(fn(y: T, _other: fn(v: T) -> Int) -> Int, (7, fn(_z: Int) -> 0))` to `(fn(value: Int, callback: fn(v: Int) -> Int) -> Int, (Int, fn(v: Int) -> Int))`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:57:39" +- Unused function `callback_map` at generic_inference_lambda_parameter_vars_errors.rue:70:4 +- Binding `result` is returned directly after it's declared at generic_inference_lambda_parameter_vars_errors.rue:78:5 +- Cannot compare `Int` to `7` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:78:21 +- Cannot infer generic `U` for `make`; specify it explicitly, e.g. `make::<...>()` at generic_inference_lambda_parameter_vars_errors.rue:91:32 +- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:94:23 +- Cannot compare `(Int, Int)` to `(5, Int)` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:98:28 +- Cannot compare `Int` to `6` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:101:24 +- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:104:21 +- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:105:22 +- Unused generic type `T` at generic_inference_lambda_parameter_vars_errors.rue:105:29 +- Cannot assign `(Int, 1)` to `(5, 2)`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:109:30 +- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:112:16 +- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:116:19 From 9d28827a87188abd5ba1964a8346f52958cbeb42 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Thu, 19 Nov 2026 01:25:32 -0500 Subject: [PATCH 2/2] Only count an argument's expected type where the callee's generics in it are covariant Where values of the callee's generics flow into the argument, such as `A` in `fn(a: A) -> B`, what they're inferred as so far can be wider than the call's solution, which would ask more of the argument than the call does: `compose(feed(fn(x) => x, five_only))` then gave `feed` the `fn(value: 5) -> Int` type that `compose` can't take. Where they only flow out of it, a solution that fits the call's final expected type has the argument fit it, whatever the arguments after it add, since the type only bounds them from above, so that condition is dropped: `wrap_after(map(fn(x) => x, 5), 6)` with `(5 | 6, Int)` expected compiles, as `wrap_after::<5 | 6>(map::<5, 5>(...), 6)` does. --- .../src/compile/expr/call_inference.rs | 52 +++++++++---------- .../rue-compiler/src/compile/expr/lambda.rs | 2 +- ...eneric_inference_lambda_parameter_vars.rue | 35 +++++++++++++ ...neric_inference_lambda_parameter_vars.yaml | 21 ++++++++ ...inference_lambda_parameter_vars_errors.rue | 4 -- ...nference_lambda_parameter_vars_errors.yaml | 41 +++++++-------- 6 files changed, 103 insertions(+), 52 deletions(-) diff --git a/crates/rue-compiler/src/compile/expr/call_inference.rs b/crates/rue-compiler/src/compile/expr/call_inference.rs index ac6a0087..4188b493 100644 --- a/crates/rue-compiler/src/compile/expr/call_inference.rs +++ b/crates/rue-compiler/src/compile/expr/call_inference.rs @@ -16,7 +16,10 @@ use rue_types::{ contains_generic, substitute_with_mappings, }; -use crate::{ArgumentFrame, Compiler, ParameterWrap, compile_expr, compile_lambda_argument}; +use crate::{ + ArgumentFrame, Compiler, ParameterWrap, compile_expr, compile_lambda_argument, + occurs_contravariantly, +}; /// What inferring a call's generics gave. pub(crate) struct InferredCall { @@ -71,8 +74,10 @@ pub(crate) fn infer_call( // only uses the type expected of it for the generics its arguments don't give a type (see // `refine_element_expected`), so it isn't solved again for it either let fallback_only = ctx.is_expected_type_fallback() && !args.is_empty(); - // Whether the type expected of the call is a type of its own, which it has to be assignable to - let expected_is_final = expected_type.is_some() && !ctx.is_expected_type_hint(); + // The type expected of the call, if it's a type of its own that the call has to be assignable + // to. One that's only a hint doesn't count (see `Compiler::with_expected_type_hint`), such as one + // that comes from what an enclosing call has inferred so far, which it can still widen + let final_expected = expected_type.filter(|_| !ctx.is_expected_type_hint() && !fallback_only); let solver = ctx.call_solver(expected); let solver = Rc::new(if fallback_only { @@ -143,15 +148,18 @@ pub(crate) fn infer_call( })); // The parameter's type is only a hint while it references the callee's generics, since - // what they're inferred as so far can still widen. Unless the call's own expected type is - // a type of its own and no argument still to be compiled can add to them: then it's what - // the call's solution will have to be, so `wrap(map(fn(x) => x, 5))` with `(5, Int)` - // expected solves `map` for `5` - let hint = function - .generics - .iter() - .any(|&generic| contains_generic(ctx.types_mut(), param, generic)) - && !(expected_is_final && order.settles(i)); + // what they're inferred as so far can still widen. It isn't one when the call's own expected + // type is final and those generics only occur where values flow out of the argument: then + // a solution that fits the call's expected type has the argument fit it, so + // `wrap(map(fn(x) => x, 5))` with `(5, Int)` expected solves `map` for `5`. Where values + // flow into the argument, such as `A` in `fn(a: A) -> B`, what they're inferred as so far + // can be wider than the solution, which would ask more of the argument + let writes = order.writes(i); + let hint = !writes.is_empty() + && (final_expected.is_none() + || writes + .iter() + .any(|&generic| occurs_contravariantly(ctx, param, generic))); // A lambda expected to be exactly the parameter's function type wraps the callee's // generics in its parameters (see `ParameterWrap`) @@ -207,11 +215,9 @@ pub(crate) fn infer_call( let mut mappings = ctx.solve_call(&solver, order.merged().clone()); // Only a call that the arguments don't solve otherwise is solved again with lambdas' untyped - // parameters as vars, so that nothing that compiled before changes. A type expected of the call - // that's only a hint doesn't count (see `Compiler::with_expected_type_hint`), such as one that - // comes from what an enclosing call has inferred so far, which it can still widen. The checks - // are made with the renamed generics restored, as the call is checked - let expected_type = expected_type.filter(|_| !ctx.is_expected_type_hint() && !fallback_only); + // parameters as vars, so that nothing that compiled before changes, and only for a final + // expected type. The checks are made with the renamed generics restored, as the call is checked + let expected_type = final_expected; restore_renamed(ctx, &mut mappings, renamed); @@ -748,15 +754,9 @@ impl ArgumentOrder { argument.is_lambda() && self.last_settled && !argument.returns_reads() } - /// Whether no argument still to be compiled, other than this one, can add to the generics in - /// its parameter type. - fn settles(&self, i: usize) -> bool { - let writes = &self.arguments[i].writes; - - self.pending - .iter() - .filter(|&&other| other != i) - .all(|&other| self.arguments[other].writes.is_disjoint(writes)) + /// The callee's generics in the argument's parameter type (see `Argument::writes`). + fn writes(&self, i: usize) -> &IndexSet { + &self.arguments[i].writes } /// Whether every argument has been compiled. diff --git a/crates/rue-compiler/src/compile/expr/lambda.rs b/crates/rue-compiler/src/compile/expr/lambda.rs index 03477e91..098a1680 100644 --- a/crates/rue-compiler/src/compile/expr/lambda.rs +++ b/crates/rue-compiler/src/compile/expr/lambda.rs @@ -338,7 +338,7 @@ fn make_references(ctx: &mut Compiler, wrapped: &[(TypeId, TypeId)]) { /// Whether the generic occurs in the type where values flow out of whoever holds a value of it, /// such as a parameter of a function type in it. -fn occurs_contravariantly(ctx: &mut Compiler, ty: TypeId, generic: TypeId) -> bool { +pub(crate) fn occurs_contravariantly(ctx: &mut Compiler, ty: TypeId, generic: TypeId) -> bool { let ty = rue_types::substitute(ctx.types_mut(), ty); let mut visited = std::collections::HashSet::new(); let mut stack = vec![(ty, true)]; diff --git a/tests/types/generic_inference_lambda_parameter_vars.rue b/tests/types/generic_inference_lambda_parameter_vars.rue index a5c3c84c..90b2de7c 100644 --- a/tests/types/generic_inference_lambda_parameter_vars.rue +++ b/tests/types/generic_inference_lambda_parameter_vars.rue @@ -191,3 +191,38 @@ test fn argument_of_a_call_with_a_final_expected_type() -> Int { let result: (5, Int) = wrap(map(fn(x) => x, 5)); result.first } + +fn wrap_after(value: T, _last: T) -> (T, Int) { + (value, 1) +} + +test fn argument_before_another_one_with_the_generic() -> Int { + // The `6` after it adds to `T` too, but `T` is still at most `5 | 6`, so `map` is solved for + // what fits that, as `wrap_after::<5 | 6>(map::<5, 5>(...), 6)` is + let result: (5 | 6, Int) = wrap_after(map(fn(x) => x, 5), 6); + result.first +} + +test fn argument_of_a_guarded_call() -> Bool { + // The guard's type is only a hint, so `map` is solved as before and the guard still checks + wrap(map(fn(x) => x, 5)) is (5, Int) +} + +fn chain(first: fn(a: A) -> B, second: fn(a: B) -> C, value: A) -> C { + second(first(value)) +} + +fn feed(_first: fn(a: A) -> B, _second: fn(a: B) -> Int) -> fn(a: A) -> Int { + fn(_x) => 1 +} + +fn compose(function: fn(a: A) -> B) -> fn(a: A) -> B { + function +} + +test fn argument_whose_generic_takes_values() -> Int { + // `compose`'s `A` is where its argument takes values, so what it's inferred as so far is only a + // hint for `feed`'s: solving `feed` for it would give `fn(value: 5) -> Int`, which isn't the + // `fn(a: Int) -> Int` that `compose` ends up needing, and this compiles as before + chain::(compose(fn(_x) => 5), compose(feed(fn(x) => x, five_only)), nil) +} diff --git a/tests/types/generic_inference_lambda_parameter_vars.yaml b/tests/types/generic_inference_lambda_parameter_vars.yaml index ecb0e4b3..b7f8a54b 100644 --- a/tests/types/generic_inference_lambda_parameter_vars.yaml +++ b/tests/types/generic_inference_lambda_parameter_vars.yaml @@ -132,6 +132,27 @@ tests: runtime_cost: 179 byte_cost: 156000 total_cost: 156179 +- name: argument_before_another_one_with_the_generic + program: (a (q . 2) (q 5)) + debug_program: (a (q 2 (q 5 2) (c (a 6 (c (a 4 (c (c (q . 2) (c (c (q . 1) (q . 2)) (c (q . 1) ()))) (q . 5))) (q . 6))) 1)) (c (c (q 2 2 (c 3 ())) (q 4 2 (q . 1))) ())) + output: "5" + runtime_cost: 179 + byte_cost: 156000 + total_cost: 156179 +- name: argument_of_a_guarded_call + program: (= (a (q . 2) (q 5)) (q . 5)) + debug_program: (a (q 9 (f (a 6 (a 4 (c (c (q . 2) (c (c (q . 1) (q . 2)) (c (q . 1) ()))) (q . 5))))) (q . 5)) (c (c (q 2 2 (c 3 ())) (q 4 1 (q . 1))) ())) + output: "1" + runtime_cost: 319 + byte_cost: 252000 + total_cost: 252319 +- name: argument_whose_generic_takes_values + program: (a (q 2 (a 2 (q 1 . 1)) (c (a (a 2 (q 1 . 5)) (q ())) ())) (c (q . 1) ())) + debug_program: (a (q 2 30 (c (a 4 (c (q . 2) (c (c (q . 1) (q 1 . 5)) (c (q . 1) ())))) (c (a 4 (a 22 (c (c (q . 2) (c (c (q . 1) (q . 2)) (c (q . 1) ()))) (c (q . 2) (c (c (q . 1) 10) (c (q . 1) ())))))) ()))) (c (c (q . 1) (c (q . 2) (c (q 4 (q . 2) (c (c (q . 1) (q 1 . 1)) (c (q . 1) ()))) (q 2 5 (c (a 2 (c 7 ())) ()))))) ())) + output: "1" + runtime_cost: 969 + byte_cost: 708000 + total_cost: 708969 diagnostics: - |- Binding `result` is returned directly after it's declared at generic_inference_lambda_parameter_vars.rue:61:5 diff --git a/tests/types/generic_inference_lambda_parameter_vars_errors.rue b/tests/types/generic_inference_lambda_parameter_vars_errors.rue index 61813fb6..19f5f23b 100644 --- a/tests/types/generic_inference_lambda_parameter_vars_errors.rue +++ b/tests/types/generic_inference_lambda_parameter_vars_errors.rue @@ -5,10 +5,6 @@ fn map(function: fn(a: A) -> B, value: A) -> B { function(value) } -fn wrap(value: T) -> (T, Int) { - (value, 1) -} - fn wrap_with(_first: T, value: T) -> (T, Int) { (value, 1) } diff --git a/tests/types/generic_inference_lambda_parameter_vars_errors.yaml b/tests/types/generic_inference_lambda_parameter_vars_errors.yaml index eff6ffcc..69480e69 100644 --- a/tests/types/generic_inference_lambda_parameter_vars_errors.yaml +++ b/tests/types/generic_inference_lambda_parameter_vars_errors.yaml @@ -1,22 +1,21 @@ diagnostics: -- Unused function `wrap` at generic_inference_lambda_parameter_vars_errors.rue:8:4 -- Unused function `apply_to` at generic_inference_lambda_parameter_vars_errors.rue:20:4 -- "Cannot assign `(fn(x: T) -> T | Int, \"hi\")` to `(fn(value: T | Int | String) -> T | Int | String, T | Int | String)`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:29:14" -- "Cannot assign `(fn(y: T) -> T, 1)` to `(fn(value: T | Int) -> T | Int, T | Int)`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:30:27" -- Condition always evaluates to `false` at generic_inference_lambda_parameter_vars_errors.rue:31:25 -- Unused function `call_back` at generic_inference_lambda_parameter_vars_errors.rue:42:4 -- Unused function `five_only` at generic_inference_lambda_parameter_vars_errors.rue:48:4 -- "Cannot assign `(fn(y: T, _other: fn(v: T) -> Int) -> Int, (7, fn(_z: Int) -> 0))` to `(fn(value: Int, callback: fn(v: Int) -> Int) -> Int, (Int, fn(v: Int) -> Int))`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:57:39" -- Unused function `callback_map` at generic_inference_lambda_parameter_vars_errors.rue:70:4 -- Binding `result` is returned directly after it's declared at generic_inference_lambda_parameter_vars_errors.rue:78:5 -- Cannot compare `Int` to `7` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:78:21 -- Cannot infer generic `U` for `make`; specify it explicitly, e.g. `make::<...>()` at generic_inference_lambda_parameter_vars_errors.rue:91:32 -- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:94:23 -- Cannot compare `(Int, Int)` to `(5, Int)` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:98:28 -- Cannot compare `Int` to `6` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:101:24 -- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:104:21 -- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:105:22 -- Unused generic type `T` at generic_inference_lambda_parameter_vars_errors.rue:105:29 -- Cannot assign `(Int, 1)` to `(5, 2)`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:109:30 -- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:112:16 -- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:116:19 +- Unused function `apply_to` at generic_inference_lambda_parameter_vars_errors.rue:16:4 +- "Cannot assign `(fn(x: T) -> T | Int, \"hi\")` to `(fn(value: T | Int | String) -> T | Int | String, T | Int | String)`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:25:14" +- "Cannot assign `(fn(y: T) -> T, 1)` to `(fn(value: T | Int) -> T | Int, T | Int)`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:26:27" +- Condition always evaluates to `false` at generic_inference_lambda_parameter_vars_errors.rue:27:25 +- Unused function `call_back` at generic_inference_lambda_parameter_vars_errors.rue:38:4 +- Unused function `five_only` at generic_inference_lambda_parameter_vars_errors.rue:44:4 +- "Cannot assign `(fn(y: T, _other: fn(v: T) -> Int) -> Int, (7, fn(_z: Int) -> 0))` to `(fn(value: Int, callback: fn(v: Int) -> Int) -> Int, (Int, fn(v: Int) -> Int))`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:53:39" +- Unused function `callback_map` at generic_inference_lambda_parameter_vars_errors.rue:66:4 +- Binding `result` is returned directly after it's declared at generic_inference_lambda_parameter_vars_errors.rue:74:5 +- Cannot compare `Int` to `7` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:74:21 +- Cannot infer generic `U` for `make`; specify it explicitly, e.g. `make::<...>()` at generic_inference_lambda_parameter_vars_errors.rue:87:32 +- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:90:23 +- Cannot compare `(Int, Int)` to `(5, Int)` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:94:28 +- Cannot compare `Int` to `6` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:97:24 +- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:100:21 +- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:101:22 +- Unused generic type `T` at generic_inference_lambda_parameter_vars_errors.rue:101:29 +- Cannot assign `(Int, 1)` to `(5, 2)`, since they are incompatible at generic_inference_lambda_parameter_vars_errors.rue:105:30 +- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:108:16 +- Cannot compare `Int` to `5` without a type guard, since the runtime value must be constrained at generic_inference_lambda_parameter_vars_errors.rue:112:19