@@ -69,7 +69,8 @@ pub fn call_callee(
6969 mut args : Vec < TypedExpr > ,
7070 source : Source ,
7171) -> Result < TypedExpr , ResolveError > {
72- for impl_arg in call. using . iter ( ) {
72+ for impl_using in call. using . iter ( ) {
73+ let impl_arg = & impl_using. ty ;
7374 let ( impl_ref, impl_poly_catalog) = resolve_impl_mention_from_type ( ctx, impl_arg) ?;
7475
7576 let imp = ctx
@@ -81,34 +82,41 @@ pub fn call_callee(
8182 let arg_concrete_trait = impl_poly_catalog. bake ( ) . resolve_trait ( & imp. target ) ?;
8283
8384 let function = ctx. asg . funcs . get ( callee. function ) . unwrap ( ) ;
84- for ( poly_impl_name, param_generic_trait) in function. impl_params . params . iter ( ) {
85- let param_concrete_trait = callee. recipe . resolve_trait ( param_generic_trait) ?;
86-
87- if arg_concrete_trait != param_concrete_trait {
88- return Err ( ResolveError :: other (
89- format ! (
90- "Implementation of {} cannot be used for {}" ,
91- arg_concrete_trait. display( ctx. asg) ,
92- param_concrete_trait. display( ctx. asg)
93- ) ,
94- impl_arg. source ,
95- ) ) ;
96- }
9785
98- if callee
99- . recipe
100- . polymorphs
101- . insert ( poly_impl_name. into ( ) , PolyValue :: Impl ( impl_ref) )
102- . is_some ( )
103- {
104- return Err ( ResolveError :: other (
105- format ! (
106- "Multiple implementations were specified for implementation parameter '${}'" ,
107- poly_impl_name
108- ) ,
109- impl_arg. source ,
110- ) ) ;
111- }
86+ let poly_impl_name = & impl_using. name ;
87+
88+ let Some ( param_generic_trait) = function. impl_params . params . get ( & impl_using. name ) else {
89+ return Err ( ResolveError :: other (
90+ format ! ( "Unknown implementation argument '${}'" , poly_impl_name) ,
91+ source,
92+ ) ) ;
93+ } ;
94+
95+ let param_concrete_trait = callee. recipe . resolve_trait ( param_generic_trait) ?;
96+
97+ if arg_concrete_trait != param_concrete_trait {
98+ return Err ( ResolveError :: other (
99+ format ! (
100+ "Implementation of {} cannot be used for {}" ,
101+ arg_concrete_trait. display( ctx. asg) ,
102+ param_concrete_trait. display( ctx. asg)
103+ ) ,
104+ impl_arg. source ,
105+ ) ) ;
106+ }
107+ if callee
108+ . recipe
109+ . polymorphs
110+ . insert ( poly_impl_name. into ( ) , PolyValue :: Impl ( impl_ref) )
111+ . is_some ( )
112+ {
113+ return Err ( ResolveError :: other (
114+ format ! (
115+ "Multiple implementations were specified for implementation parameter '${}'" ,
116+ poly_impl_name
117+ ) ,
118+ impl_arg. source ,
119+ ) ) ;
112120 }
113121
114122 // NOTE: We will need to populate the callee's poly recipe with `callee.recipe.polymorphs.insert()`
0 commit comments