mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Explicitly disallow ability definitions in nested scopes
Abilities can only be defined on the toplevel of a module. There is a technical reason to this, which is that during type solving we must introduce all abilities at the very beginning, and we need to make sure ranks are correct. But there is a practical reason as well, which is that nested ability definitions don't seem to be very useful. Note that specializations can be nested, and are allowed to be. Also, we can revisit this in the future. I just don't want experiments to break right now because someone uses an ability in a nested scope where we don't expect. Closes #2878
This commit is contained in:
parent
340f6b7c88
commit
f129777115
5 changed files with 89 additions and 31 deletions
|
@ -278,6 +278,12 @@ pub struct AbilityMember<'a> {
|
|||
pub typ: Loc<TypeAnnotation<'a>>,
|
||||
}
|
||||
|
||||
impl AbilityMember<'_> {
|
||||
pub fn region(&self) -> Region {
|
||||
Region::across_all([self.name.region, self.typ.region].iter())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum TypeDef<'a> {
|
||||
/// A type alias. This is like a standalone annotation, except the pattern
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue