diff --git a/reporting/src/error/canonicalize.rs b/reporting/src/error/canonicalize.rs index 24a27f5e9c..2a806844f5 100644 --- a/reporting/src/error/canonicalize.rs +++ b/reporting/src/error/canonicalize.rs @@ -615,6 +615,16 @@ pub fn can_problem<'b>( alloc.reflow(":"), ]), alloc.region(lines.convert_region(region)), + alloc.concat(vec![ + alloc.reflow("Abilities are not types, but you can add an ability constraint to a type variable "), + alloc.type_variable("a".into()), + alloc.reflow(" by writing"), + ]), + alloc.type_block(alloc.concat(vec![ + alloc.reflow("| a has "), + alloc.symbol_unqualified(ability), + ])), + alloc.reflow(" at the end of the type."), ]); title = ALIAS_USES_ABILITY.to_string(); severity = Severity::RuntimeError; diff --git a/reporting/tests/test_reporting.rs b/reporting/tests/test_reporting.rs index 73b427947a..f3377fbfd4 100644 --- a/reporting/tests/test_reporting.rs +++ b/reporting/tests/test_reporting.rs @@ -9030,6 +9030,13 @@ I need all branches in an `if` to have the same type! 3│ Alias : Ability ^^^^^ + Abilities are not types, but you can add an ability constraint to a + type variable `a` by writing + + | a has Ability + + at the end of the type. + ── UNUSED DEFINITION ─────────────────────────────────────────────────────────── `ab` is not used anywhere in your code.