Merge pull request #2276 from rtfeldman/i/2265

Parse "as" aliases into tag/args rather than arbitrary annotations
This commit is contained in:
Folkert de Vries 2021-12-27 20:56:48 +01:00 committed by GitHub
commit bb935948aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 506 additions and 284 deletions

View file

@ -225,6 +225,12 @@ pub struct PrecedenceConflict<'a> {
pub expr: &'a Loc<Expr<'a>>,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct AliasHeader<'a> {
pub name: Loc<&'a str>,
pub vars: &'a [Loc<Pattern<'a>>],
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Def<'a> {
// TODO in canonicalization, validate the pattern; only certain patterns
@ -236,8 +242,7 @@ pub enum Def<'a> {
///
/// Foo : Bar Baz
Alias {
name: Loc<&'a str>,
vars: &'a [Loc<Pattern<'a>>],
header: AliasHeader<'a>,
ann: Loc<TypeAnnotation<'a>>,
},
@ -291,7 +296,7 @@ pub enum TypeAnnotation<'a> {
As(
&'a Loc<TypeAnnotation<'a>>,
&'a [CommentOrNewline<'a>],
&'a Loc<TypeAnnotation<'a>>,
AliasHeader<'a>,
),
Record {