Improve error message

This commit is contained in:
ayazhafiz 2022-04-07 22:26:17 -04:00
parent 02e1a98cac
commit 13a17f1858
2 changed files with 17 additions and 0 deletions

View file

@ -615,6 +615,16 @@ pub fn can_problem<'b>(
alloc.reflow(":"), alloc.reflow(":"),
]), ]),
alloc.region(lines.convert_region(region)), 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(); title = ALIAS_USES_ABILITY.to_string();
severity = Severity::RuntimeError; severity = Severity::RuntimeError;

View file

@ -9030,6 +9030,13 @@ I need all branches in an `if` to have the same type!
3 Alias : Ability 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 UNUSED DEFINITION
`ab` is not used anywhere in your code. `ab` is not used anywhere in your code.