@@ -247,3 +247,76 @@ pub(crate) fn fat_call_on_constant(span: SpanId) -> ReifyDiagnostic {
247247
248248 diagnostic
249249}
250+
251+ // Synthetic body diagnostics
252+
253+ /// ICE: monomorphized closure type has wrong parameter count for a synthetic binary
254+ /// operation body.
255+ #[ coverage( off) ]
256+ pub ( crate ) fn synthetic_binary_arity_mismatch (
257+ span : SpanId ,
258+ name : Symbol < ' _ > ,
259+ actual_params : usize ,
260+ ) -> ReifyDiagnostic < Critical > {
261+ let mut diagnostic = Diagnostic :: new ( ReifyDiagnosticCategory :: TypeInvariant , Critical :: BUG )
262+ . primary ( Label :: new (
263+ span,
264+ format ! ( "monomorphized type of `{name}` has {actual_params} parameters, expected 2" ) ,
265+ ) ) ;
266+
267+ diagnostic. add_message ( Message :: note (
268+ "binary operations require exactly 2 parameters after monomorphization" ,
269+ ) ) ;
270+
271+ diagnostic. add_message ( Message :: help (
272+ "type checking should have ensured the correct arity before reification" ,
273+ ) ) ;
274+
275+ diagnostic
276+ }
277+
278+ /// ICE: monomorphized closure type has wrong parameter count for a synthetic unary
279+ /// operation body.
280+ #[ coverage( off) ]
281+ pub ( crate ) fn synthetic_unary_arity_mismatch (
282+ span : SpanId ,
283+ name : Symbol < ' _ > ,
284+ actual_params : usize ,
285+ ) -> ReifyDiagnostic < Critical > {
286+ let mut diagnostic = Diagnostic :: new ( ReifyDiagnosticCategory :: TypeInvariant , Critical :: BUG )
287+ . primary ( Label :: new (
288+ span,
289+ format ! ( "monomorphized type of `{name}` has {actual_params} parameters, expected 1" ) ,
290+ ) ) ;
291+
292+ diagnostic. add_message ( Message :: note (
293+ "unary operations require exactly 1 parameter after monomorphization" ,
294+ ) ) ;
295+
296+ diagnostic. add_message ( Message :: help (
297+ "type checking should have ensured the correct arity before reification" ,
298+ ) ) ;
299+
300+ diagnostic
301+ }
302+
303+ /// Intrinsic cannot be used as a first-class value.
304+ pub ( crate ) fn intrinsic_not_first_class (
305+ span : SpanId ,
306+ name : Symbol < ' _ > ,
307+ ) -> ReifyDiagnostic < Critical > {
308+ let mut diagnostic =
309+ Diagnostic :: new ( ReifyDiagnosticCategory :: UnsupportedFeature , Critical :: ERROR ) . primary (
310+ Label :: new ( span, format ! ( "`{name}` cannot be used as a value" ) ) ,
311+ ) ;
312+
313+ diagnostic. add_message ( Message :: note ( format ! (
314+ "`{name}` is a syntactic form that is only valid at a call site"
315+ ) ) ) ;
316+
317+ diagnostic. add_message ( Message :: help (
318+ "call this intrinsic directly instead of passing it as an argument" ,
319+ ) ) ;
320+
321+ diagnostic
322+ }
0 commit comments