Split up Defs into TypeDef and ValueDef

Just a refactoring PR. This is useful because during canonicalization
we always process type defs first, then value defs. With abilities this
distinction continues to grow; in that case, we have patterns associated
with types that we want to process before patterns from values.
This commit is contained in:
Ayaz Hafiz 2022-04-06 22:18:57 -04:00
parent 37729c08cc
commit a3ac68a41f
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
46 changed files with 1611 additions and 1407 deletions

View file

@ -16,7 +16,7 @@ use roc_collections::all::{default_hasher, ImMap, MutMap, MutSet, SendMap};
use roc_error_macros::{todo_abilities, todo_opaques};
use roc_module::ident::Lowercase;
use roc_module::symbol::Symbol;
use roc_parse::ast::{self, TypeHeader};
use roc_parse::ast::{self, TypeDef, TypeHeader, ValueDef as AstValueDef};
use roc_parse::pattern::PatternType;
use roc_problem::can::{Problem, RuntimeError};
use roc_region::all::{Loc, Region};
@ -133,7 +133,7 @@ fn to_pending_def<'a>(
use roc_parse::ast::Def::*;
match def {
Annotation(loc_pattern, loc_ann) => {
Value(AstValueDef::Annotation(loc_pattern, loc_ann)) => {
// This takes care of checking for shadowing and adding idents to scope.
let (output, loc_can_pattern) = pattern::to_pattern_id(
env,
@ -148,7 +148,7 @@ fn to_pending_def<'a>(
PendingDef::AnnotationOnly(loc_pattern, loc_can_pattern, loc_ann),
))
}
Body(loc_pattern, loc_expr) => {
Value(AstValueDef::Body(loc_pattern, loc_expr)) => {
// This takes care of checking for shadowing and adding idents to scope.
let (output, loc_can_pattern) = pattern::to_pattern_id(
env,
@ -164,13 +164,13 @@ fn to_pending_def<'a>(
))
}
AnnotatedBody {
Value(AstValueDef::AnnotatedBody {
ann_pattern,
ann_type,
comment: _,
body_pattern,
body_expr,
} => {
}) => {
if ann_pattern.value.equivalent(&body_pattern.value) {
// NOTE: Pick the body pattern, picking the annotation one is
// incorrect in the presence of optional record fields!
@ -199,10 +199,10 @@ fn to_pending_def<'a>(
}
}
roc_parse::ast::Def::Alias {
Type(TypeDef::Alias {
header: TypeHeader { name, vars },
ann,
} => {
}) => {
let region = Region::span_across(&name.region, &ann.region);
match scope.introduce(
@ -261,10 +261,10 @@ fn to_pending_def<'a>(
}
}
Opaque { .. } => todo_opaques!(),
Ability { .. } => todo_abilities!(),
Type(TypeDef::Opaque { .. }) => todo_opaques!(),
Type(TypeDef::Ability { .. }) => todo_abilities!(),
Expect(_) => todo!(),
Value(AstValueDef::Expect(_)) => todo!(),
SpaceBefore(sub_def, _) | SpaceAfter(sub_def, _) => {
to_pending_def(env, sub_def, scope, pattern_type)
@ -608,7 +608,7 @@ fn canonicalize_pending_def<'a>(
pattern_id: loc_can_pattern,
expr_id: env.pool.add(loc_can_expr),
type_id: annotation,
rigids: rigids,
rigids,
expr_var: env.var_store.fresh(),
};

View file

@ -72,7 +72,7 @@ pub fn def_to_def2<'a>(
def_to_def2(arena, env, scope, inner_def, region)
}
}
Body(&loc_pattern, &loc_expr) => {
Value(roc_parse::ast::ValueDef::Body(&loc_pattern, &loc_expr)) => {
let expr2 = loc_expr_to_expr2(arena, loc_expr, env, scope, region).0;
let expr_id = env.pool.add(expr2);

View file

@ -11,7 +11,7 @@ use roc_fmt::Buf;
use roc_module::called_via::{BinOp, UnaryOp};
use roc_parse::ast::{
AbilityMember, AssignedField, Collection, Expr, Has, HasClause, Pattern, Spaced, StrLiteral,
StrSegment, Tag, TypeAnnotation, TypeHeader, WhenBranch,
StrSegment, Tag, TypeAnnotation, TypeDef, TypeHeader, ValueDef, WhenBranch,
};
use roc_parse::header::{
AppHeader, ExposedName, HostedHeader, ImportsEntry, InterfaceHeader, ModuleName, PackageEntry,
@ -445,54 +445,36 @@ impl<'a, T: RemoveSpaces<'a>> RemoveSpaces<'a> for &'a T {
}
}
impl<'a> RemoveSpaces<'a> for Def<'a> {
impl<'a> RemoveSpaces<'a> for TypeDef<'a> {
fn remove_spaces(&self, arena: &'a Bump) -> Self {
use TypeDef::*;
match *self {
Def::Annotation(a, b) => {
Def::Annotation(a.remove_spaces(arena), b.remove_spaces(arena))
}
Def::Alias {
Alias {
header: TypeHeader { name, vars },
ann,
} => Def::Alias {
} => Alias {
header: TypeHeader {
name: name.remove_spaces(arena),
vars: vars.remove_spaces(arena),
},
ann: ann.remove_spaces(arena),
},
Def::Opaque {
Opaque {
header: TypeHeader { name, vars },
typ,
} => Def::Opaque {
} => Opaque {
header: TypeHeader {
name: name.remove_spaces(arena),
vars: vars.remove_spaces(arena),
},
typ: typ.remove_spaces(arena),
},
Def::Body(a, b) => Def::Body(
arena.alloc(a.remove_spaces(arena)),
arena.alloc(b.remove_spaces(arena)),
),
Def::AnnotatedBody {
ann_pattern,
ann_type,
comment: _,
body_pattern,
body_expr,
} => Def::AnnotatedBody {
ann_pattern: arena.alloc(ann_pattern.remove_spaces(arena)),
ann_type: arena.alloc(ann_type.remove_spaces(arena)),
comment: None,
body_pattern: arena.alloc(body_pattern.remove_spaces(arena)),
body_expr: arena.alloc(body_expr.remove_spaces(arena)),
},
Def::Ability {
Ability {
header: TypeHeader { name, vars },
loc_has,
members,
} => Def::Ability {
} => Ability {
header: TypeHeader {
name: name.remove_spaces(arena),
vars: vars.remove_spaces(arena),
@ -500,7 +482,43 @@ impl<'a> RemoveSpaces<'a> for Def<'a> {
loc_has: loc_has.remove_spaces(arena),
members: members.remove_spaces(arena),
},
Def::Expect(a) => Def::Expect(arena.alloc(a.remove_spaces(arena))),
}
}
}
impl<'a> RemoveSpaces<'a> for ValueDef<'a> {
fn remove_spaces(&self, arena: &'a Bump) -> Self {
use ValueDef::*;
match *self {
Annotation(a, b) => Annotation(a.remove_spaces(arena), b.remove_spaces(arena)),
Body(a, b) => Body(
arena.alloc(a.remove_spaces(arena)),
arena.alloc(b.remove_spaces(arena)),
),
AnnotatedBody {
ann_pattern,
ann_type,
comment: _,
body_pattern,
body_expr,
} => AnnotatedBody {
ann_pattern: arena.alloc(ann_pattern.remove_spaces(arena)),
ann_type: arena.alloc(ann_type.remove_spaces(arena)),
comment: None,
body_pattern: arena.alloc(body_pattern.remove_spaces(arena)),
body_expr: arena.alloc(body_expr.remove_spaces(arena)),
},
Expect(a) => Expect(arena.alloc(a.remove_spaces(arena))),
}
}
}
impl<'a> RemoveSpaces<'a> for Def<'a> {
fn remove_spaces(&self, arena: &'a Bump) -> Self {
match *self {
Def::Type(def) => Def::Type(def.remove_spaces(arena)),
Def::Value(def) => Def::Value(def.remove_spaces(arena)),
Def::NotYetImplemented(a) => Def::NotYetImplemented(a),
Def::SpaceBefore(a, _) | Def::SpaceAfter(a, _) => a.remove_spaces(arena),
}

View file

@ -49,11 +49,12 @@ pub struct CanDefs {
pub can_defs_by_symbol: MutMap<Symbol, Def>,
pub aliases: SendMap<Symbol, Alias>,
}
/// A Def that has had patterns and type annnotations canonicalized,
/// but no Expr canonicalization has happened yet. Also, it has had spaces
/// and nesting resolved, and knows whether annotations are standalone or not.
#[derive(Debug, Clone, PartialEq)]
enum PendingDef<'a> {
enum PendingValueDef<'a> {
/// A standalone annotation with no body
AnnotationOnly(
&'a Loc<ast::Pattern<'a>>,
@ -73,7 +74,10 @@ enum PendingDef<'a> {
&'a Loc<ast::TypeAnnotation<'a>>,
&'a Loc<ast::Expr<'a>>,
),
}
#[derive(Debug, Clone, PartialEq)]
enum PendingTypeDef<'a> {
/// A structural or opaque type alias, e.g. `Ints : List Int` or `Age := U32` respectively.
Alias {
name: Loc<Symbol>,
@ -206,56 +210,40 @@ pub fn canonicalize_defs<'a>(
let num_defs = loc_defs.len();
let mut refs_by_symbol = MutMap::default();
let mut can_defs_by_symbol = HashMap::with_capacity_and_hasher(num_defs, default_hasher());
let mut pending = Vec::with_capacity(num_defs); // TODO bump allocate this!
// Canonicalize all the patterns, record shadowing problems, and store
// the ast::Expr values in pending_exprs for further canonicalization
// once we've finished assembling the entire scope.
let mut type_defs = Vec::with_capacity(num_defs);
let mut value_defs = Vec::with_capacity(num_defs);
for loc_def in loc_defs {
match to_pending_def(env, var_store, &loc_def.value, &mut scope, pattern_type) {
None => (),
Some((new_output, pending_def)) => {
// store the top-level defs, used to ensure that closures won't capture them
if let PatternType::TopLevelDef = pattern_type {
match &pending_def {
PendingDef::AnnotationOnly(_, loc_can_pattern, _)
| PendingDef::Body(_, loc_can_pattern, _)
| PendingDef::TypedBody(_, loc_can_pattern, _, _) => {
env.top_level_symbols.extend(
bindings_from_patterns(std::iter::once(loc_can_pattern))
.iter()
.map(|t| t.0),
)
match loc_def.value.unroll_def() {
Ok(type_def) => type_defs.push(Loc::at(loc_def.region, type_def)),
Err(value_def) => value_defs.push(Loc::at(loc_def.region, value_def)),
}
}
// Type definitions aren't value definitions, so we don't need to do
// anything for them here.
PendingDef::Alias { .. } | PendingDef::InvalidAlias { .. } => {}
}
}
// Record the ast::Expr for later. We'll do another pass through these
// once we have the entire scope assembled. If we were to canonicalize
// the exprs right now, they wouldn't have symbols in scope from defs
// that get would have gotten added later in the defs list!
pending.push(pending_def);
// We need to canonicalize all the type defs first.
let pending_type_defs = type_defs
.into_iter()
.filter_map(|loc_def| {
to_pending_type_def(env, &loc_def.value, &mut scope).map(|(new_output, pending_def)| {
output.union(new_output);
}
}
}
pending_def
})
})
.collect::<Vec<_>>();
if cfg!(debug_assertions) {
env.home.register_debug_idents(&env.ident_ids);
}
let mut aliases = SendMap::default();
let mut value_defs = Vec::new();
let mut alias_defs = MutMap::default();
let mut referenced_type_symbols = MutMap::default();
for pending_def in pending.into_iter() {
for pending_def in pending_type_defs.into_iter() {
match pending_def {
PendingDef::Alias {
PendingTypeDef::Alias {
name,
vars,
ann,
@ -271,7 +259,7 @@ pub fn canonicalize_defs<'a>(
alias_defs.insert(name.value, (name, vars, ann, kind));
}
other => value_defs.push(other),
PendingTypeDef::InvalidAlias { .. } => { /* ignore */ }
}
}
@ -373,8 +361,41 @@ pub fn canonicalize_defs<'a>(
// Now that we have the scope completely assembled, and shadowing resolved,
// we're ready to canonicalize any body exprs.
for pending_def in value_defs.into_iter() {
output = canonicalize_pending_def(
// Canonicalize all the patterns, record shadowing problems, and store
// the ast::Expr values in pending_exprs for further canonicalization
// once we've finished assembling the entire scope.
let mut pending_value_defs = Vec::with_capacity(value_defs.len());
for loc_def in value_defs.into_iter() {
match to_pending_value_def(env, var_store, &loc_def.value, &mut scope, pattern_type) {
None => { /* skip */ }
Some((new_output, pending_def)) => {
// store the top-level defs, used to ensure that closures won't capture them
if let PatternType::TopLevelDef = pattern_type {
match &pending_def {
PendingValueDef::AnnotationOnly(_, loc_can_pattern, _)
| PendingValueDef::Body(_, loc_can_pattern, _)
| PendingValueDef::TypedBody(_, loc_can_pattern, _, _) => {
env.top_level_symbols.extend(
bindings_from_patterns(std::iter::once(loc_can_pattern))
.iter()
.map(|t| t.0),
)
}
}
}
// Record the ast::Expr for later. We'll do another pass through these
// once we have the entire scope assembled. If we were to canonicalize
// the exprs right now, they wouldn't have symbols in scope from defs
// that get would have gotten added later in the defs list!
pending_value_defs.push(pending_def);
output.union(new_output);
}
}
}
for pending_def in pending_value_defs.into_iter() {
output = canonicalize_pending_value_def(
env,
pending_def,
output,
@ -910,9 +931,9 @@ fn add_annotation_aliases(
// TODO trim down these arguments!
#[allow(clippy::too_many_arguments)]
#[allow(clippy::cognitive_complexity)]
fn canonicalize_pending_def<'a>(
fn canonicalize_pending_value_def<'a>(
env: &mut Env<'a>,
pending_def: PendingDef<'a>,
pending_def: PendingValueDef<'a>,
mut output: Output,
scope: &mut Scope,
can_defs_by_symbol: &mut MutMap<Symbol, Def>,
@ -920,7 +941,7 @@ fn canonicalize_pending_def<'a>(
refs_by_symbol: &mut MutMap<Symbol, (Region, References)>,
aliases: &mut ImMap<Symbol, Alias>,
) -> Output {
use PendingDef::*;
use PendingValueDef::*;
// Make types for the body expr, even if we won't end up having a body.
let expr_var = var_store.fresh();
@ -1047,11 +1068,6 @@ fn canonicalize_pending_def<'a>(
}
}
Alias { .. } => unreachable!("Aliases are handled in a separate pass"),
InvalidAlias { .. } => {
// invalid aliases and opaques (shadowed, incorrect patterns) get ignored
}
TypedBody(_loc_pattern, loc_can_pattern, loc_ann, loc_expr) => {
let type_annotation =
canonicalize_annotation(env, scope, &loc_ann.value, loc_ann.region, var_store);
@ -1446,85 +1462,14 @@ fn closure_recursivity(symbol: Symbol, closures: &MutMap<Symbol, References>) ->
Recursive::NotRecursive
}
fn to_pending_def<'a>(
fn to_pending_type_def<'a>(
env: &mut Env<'a>,
var_store: &mut VarStore,
def: &'a ast::Def<'a>,
def: &'a ast::TypeDef<'a>,
scope: &mut Scope,
pattern_type: PatternType,
) -> Option<(Output, PendingDef<'a>)> {
use roc_parse::ast::Def::*;
) -> Option<(Output, PendingTypeDef<'a>)> {
use ast::TypeDef::*;
match def {
Annotation(loc_pattern, loc_ann) => {
// This takes care of checking for shadowing and adding idents to scope.
let (output, loc_can_pattern) = canonicalize_pattern(
env,
var_store,
scope,
pattern_type,
&loc_pattern.value,
loc_pattern.region,
);
Some((
output,
PendingDef::AnnotationOnly(loc_pattern, loc_can_pattern, loc_ann),
))
}
Body(loc_pattern, loc_expr) => {
// This takes care of checking for shadowing and adding idents to scope.
let (output, loc_can_pattern) = canonicalize_pattern(
env,
var_store,
scope,
pattern_type,
&loc_pattern.value,
loc_pattern.region,
);
Some((
output,
PendingDef::Body(loc_pattern, loc_can_pattern, loc_expr),
))
}
AnnotatedBody {
ann_pattern,
ann_type,
comment: _,
body_pattern,
body_expr,
} => {
if ann_pattern.value.equivalent(&body_pattern.value) {
// NOTE: Pick the body pattern, picking the annotation one is
// incorrect in the presence of optional record fields!
//
// { x, y } : { x : Int, y ? Bool }*
// { x, y ? False } = rec
Some(pending_typed_body(
env,
body_pattern,
ann_type,
body_expr,
var_store,
scope,
pattern_type,
))
} else {
// the pattern of the annotation does not match the pattern of the body direc
env.problems.push(Problem::SignatureDefMismatch {
annotation_pattern: ann_pattern.region,
def_pattern: body_pattern.region,
});
// TODO: Should we instead build some PendingDef::InvalidAnnotatedBody ? This would
// remove the `Option` on this function (and be probably more reliable for further
// problem/error reporting)
None
}
}
Alias {
header: TypeHeader { name, vars },
ann,
@ -1571,7 +1516,7 @@ fn to_pending_def<'a>(
return Some((
Output::default(),
PendingDef::InvalidAlias { kind },
PendingTypeDef::InvalidAlias { kind },
));
}
}
@ -1582,7 +1527,7 @@ fn to_pending_def<'a>(
value: symbol,
};
let pending_def = PendingDef::Alias {
let pending_def = PendingTypeDef::Alias {
name,
vars: can_rigids,
ann,
@ -1598,20 +1543,12 @@ fn to_pending_def<'a>(
shadow: loc_shadowed_symbol,
});
Some((Output::default(), PendingDef::InvalidAlias { kind }))
Some((Output::default(), PendingTypeDef::InvalidAlias { kind }))
}
}
}
Ability { .. } => todo_abilities!(),
Expect(_condition) => todo!(),
SpaceBefore(sub_def, _) | SpaceAfter(sub_def, _) => {
to_pending_def(env, var_store, sub_def, scope, pattern_type)
}
NotYetImplemented(s) => todo!("{}", s),
}
}
@ -1623,7 +1560,7 @@ fn pending_typed_body<'a>(
var_store: &mut VarStore,
scope: &mut Scope,
pattern_type: PatternType,
) -> (Output, PendingDef<'a>) {
) -> (Output, PendingValueDef<'a>) {
// This takes care of checking for shadowing and adding idents to scope.
let (output, loc_can_pattern) = canonicalize_pattern(
env,
@ -1636,10 +1573,93 @@ fn pending_typed_body<'a>(
(
output,
PendingDef::TypedBody(loc_pattern, loc_can_pattern, loc_ann, loc_expr),
PendingValueDef::TypedBody(loc_pattern, loc_can_pattern, loc_ann, loc_expr),
)
}
fn to_pending_value_def<'a>(
env: &mut Env<'a>,
var_store: &mut VarStore,
def: &'a ast::ValueDef<'a>,
scope: &mut Scope,
pattern_type: PatternType,
) -> Option<(Output, PendingValueDef<'a>)> {
use ast::ValueDef::*;
match def {
Annotation(loc_pattern, loc_ann) => {
// This takes care of checking for shadowing and adding idents to scope.
let (output, loc_can_pattern) = canonicalize_pattern(
env,
var_store,
scope,
pattern_type,
&loc_pattern.value,
loc_pattern.region,
);
Some((
output,
PendingValueDef::AnnotationOnly(loc_pattern, loc_can_pattern, loc_ann),
))
}
Body(loc_pattern, loc_expr) => {
// This takes care of checking for shadowing and adding idents to scope.
let (output, loc_can_pattern) = canonicalize_pattern(
env,
var_store,
scope,
pattern_type,
&loc_pattern.value,
loc_pattern.region,
);
Some((
output,
PendingValueDef::Body(loc_pattern, loc_can_pattern, loc_expr),
))
}
AnnotatedBody {
ann_pattern,
ann_type,
comment: _,
body_pattern,
body_expr,
} => {
if ann_pattern.value.equivalent(&body_pattern.value) {
// NOTE: Pick the body pattern, picking the annotation one is
// incorrect in the presence of optional record fields!
//
// { x, y } : { x : Int, y ? Bool }*
// { x, y ? False } = rec
Some(pending_typed_body(
env,
body_pattern,
ann_type,
body_expr,
var_store,
scope,
pattern_type,
))
} else {
// the pattern of the annotation does not match the pattern of the body direc
env.problems.push(Problem::SignatureDefMismatch {
annotation_pattern: ann_pattern.region,
def_pattern: body_pattern.region,
});
// TODO: Should we instead build some PendingValueDef::InvalidAnnotatedBody ? This would
// remove the `Option` on this function (and be probably more reliable for further
// problem/error reporting)
None
}
}
Expect(_condition) => todo!(),
}
}
/// Make aliases recursive
fn correct_mutual_recursive_type_alias<'a>(
env: &mut Env<'a>,

View file

@ -6,7 +6,7 @@ use roc_module::called_via::BinOp::Pizza;
use roc_module::called_via::{BinOp, CalledVia};
use roc_module::ident::ModuleName;
use roc_parse::ast::Expr::{self, *};
use roc_parse::ast::{AssignedField, Def, WhenBranch};
use roc_parse::ast::{AssignedField, Def, TypeDef, ValueDef, WhenBranch};
use roc_region::all::{Loc, Region};
// BinOp precedence logic adapted from Gluon by Markus Westerlind
@ -88,15 +88,21 @@ fn desugar_def_helps<'a>(
})
}
pub fn desugar_def<'a>(arena: &'a Bump, def: &'a Def<'a>) -> Def<'a> {
use roc_parse::ast::Def::*;
fn desugar_type_def<'a>(def: &'a TypeDef<'a>) -> TypeDef<'a> {
use TypeDef::*;
match def {
Body(loc_pattern, loc_expr) => Body(loc_pattern, desugar_expr(arena, loc_expr)),
SpaceBefore(def, _) | SpaceAfter(def, _) => desugar_def(arena, def),
alias @ Alias { .. } => *alias,
opaque @ Opaque { .. } => *opaque,
ability @ Ability { .. } => *ability,
}
}
fn desugar_value_def<'a>(arena: &'a Bump, def: &'a ValueDef<'a>) -> ValueDef<'a> {
use ValueDef::*;
match def {
Body(loc_pattern, loc_expr) => Body(loc_pattern, desugar_expr(arena, loc_expr)),
ann @ Annotation(_, _) => *ann,
AnnotatedBody {
ann_pattern,
@ -115,6 +121,16 @@ pub fn desugar_def<'a>(arena: &'a Bump, def: &'a Def<'a>) -> Def<'a> {
let desugared_condition = &*arena.alloc(desugar_expr(arena, condition));
Expect(desugared_condition)
}
}
}
pub fn desugar_def<'a>(arena: &'a Bump, def: &'a Def<'a>) -> Def<'a> {
use roc_parse::ast::Def::*;
match def {
Type(type_def) => Type(desugar_type_def(type_def)),
Value(value_def) => Value(desugar_value_def(arena, value_def)),
SpaceBefore(def, _) | SpaceAfter(def, _) => desugar_def(arena, def),
NotYetImplemented(s) => todo!("{}", s),
}
}

View file

@ -9,20 +9,28 @@ use roc_region::all::Loc;
impl<'a> Formattable for Def<'a> {
fn is_multiline(&self) -> bool {
use roc_parse::ast::Def::*;
use roc_parse::ast::TypeDef::*;
use roc_parse::ast::ValueDef::*;
match self {
Type(def) => match def {
Alias { ann, .. } => ann.is_multiline(),
Opaque { typ, .. } => typ.is_multiline(),
Ability { members, .. } => members.iter().any(|d| d.is_multiline()),
},
Value(def) => match def {
Annotation(loc_pattern, loc_annotation) => {
loc_pattern.is_multiline() || loc_annotation.is_multiline()
}
Body(loc_pattern, loc_expr) => loc_pattern.is_multiline() || loc_expr.is_multiline(),
Body(loc_pattern, loc_expr) => {
loc_pattern.is_multiline() || loc_expr.is_multiline()
}
AnnotatedBody { .. } => true,
Expect(loc_expr) => loc_expr.is_multiline(),
},
SpaceBefore(sub_def, spaces) | SpaceAfter(sub_def, spaces) => {
spaces.iter().any(|s| s.is_comment()) || sub_def.is_multiline()
}
Ability { members, .. } => members.iter().any(|d| d.is_multiline()),
NotYetImplemented(s) => todo!("{}", s),
}
}
@ -35,30 +43,11 @@ impl<'a> Formattable for Def<'a> {
indent: u16,
) {
use roc_parse::ast::Def::*;
use roc_parse::ast::TypeDef::*;
use roc_parse::ast::ValueDef::*;
match self {
Annotation(loc_pattern, loc_annotation) => {
loc_pattern.format(buf, indent);
if loc_annotation.is_multiline() {
buf.push_str(" :");
loc_annotation.format_with_options(
buf,
Parens::NotNeeded,
Newlines::Yes,
indent + INDENT,
);
} else {
buf.spaces(1);
buf.push_str(":");
buf.spaces(1);
loc_annotation.format_with_options(
buf,
Parens::NotNeeded,
Newlines::No,
indent,
);
}
}
Type(def) => match def {
Alias {
header: TypeHeader { name, vars },
ann,
@ -75,7 +64,7 @@ impl<'a> Formattable for Def<'a> {
fmt_pattern(buf, &var.value, indent, Parens::NotNeeded);
}
buf.push_str(match self {
buf.push_str(match def {
Alias { .. } => " :",
Opaque { .. } => " :=",
_ => unreachable!(),
@ -110,6 +99,30 @@ impl<'a> Formattable for Def<'a> {
}
}
}
},
Value(def) => match def {
Annotation(loc_pattern, loc_annotation) => {
loc_pattern.format(buf, indent);
if loc_annotation.is_multiline() {
buf.push_str(" :");
loc_annotation.format_with_options(
buf,
Parens::NotNeeded,
Newlines::Yes,
indent + INDENT,
);
} else {
buf.spaces(1);
buf.push_str(":");
buf.spaces(1);
loc_annotation.format_with_options(
buf,
Parens::NotNeeded,
Newlines::No,
indent,
);
}
}
Body(loc_pattern, loc_expr) => {
fmt_body(buf, &loc_pattern.value, &loc_expr.value, indent);
}
@ -133,6 +146,7 @@ impl<'a> Formattable for Def<'a> {
buf.newline();
fmt_body(buf, &body_pattern.value, &body_expr.value, indent);
}
},
SpaceBefore(sub_def, spaces) => {
fmt_spaces(buf, spaces.iter(), indent);

View file

@ -7,9 +7,9 @@ use roc_can::scope::Scope;
use roc_error_macros::todo_abilities;
use roc_module::ident::ModuleName;
use roc_module::symbol::IdentIds;
use roc_parse::ast::CommentOrNewline;
use roc_parse::ast::{self, TypeHeader};
use roc_parse::ast::{AssignedField, Def};
use roc_parse::ast::{CommentOrNewline, TypeDef, ValueDef};
use roc_region::all::Loc;
// Documentation generation requirements
@ -166,7 +166,8 @@ fn generate_entry_doc<'a>(
(new_acc, Some(comments_or_new_lines))
}
Def::Annotation(loc_pattern, loc_ann) => match loc_pattern.value {
Def::Value(def) => match def {
ValueDef::Annotation(loc_pattern, loc_ann) => match loc_pattern.value {
Pattern::Identifier(identifier) => {
// Check if the definition is exposed
if ident_ids.get_id(&identifier.into()).is_some() {
@ -175,7 +176,8 @@ fn generate_entry_doc<'a>(
name,
type_annotation: type_to_docs(false, loc_ann.value),
type_vars: Vec::new(),
docs: before_comments_or_new_lines.and_then(comments_or_new_lines_to_docs),
docs: before_comments_or_new_lines
.and_then(comments_or_new_lines_to_docs),
};
acc.push(DocEntry::DocDef(doc_def));
}
@ -184,7 +186,8 @@ fn generate_entry_doc<'a>(
_ => (acc, None),
},
Def::AnnotatedBody {
ValueDef::AnnotatedBody {
ann_pattern,
ann_type,
..
@ -196,7 +199,8 @@ fn generate_entry_doc<'a>(
name: identifier.to_string(),
type_annotation: type_to_docs(false, ann_type.value),
type_vars: Vec::new(),
docs: before_comments_or_new_lines.and_then(comments_or_new_lines_to_docs),
docs: before_comments_or_new_lines
.and_then(comments_or_new_lines_to_docs),
};
acc.push(DocEntry::DocDef(doc_def));
}
@ -206,7 +210,13 @@ fn generate_entry_doc<'a>(
_ => (acc, None),
},
Def::Alias {
ValueDef::Body(_, _) => (acc, None),
ValueDef::Expect(c) => todo!("documentation for tests {:?}", c),
},
Def::Type(def) => match def {
TypeDef::Alias {
header: TypeHeader { name, vars },
ann,
} => {
@ -229,7 +239,7 @@ fn generate_entry_doc<'a>(
(acc, None)
}
Def::Opaque {
TypeDef::Opaque {
header: TypeHeader { name, vars },
..
} => {
@ -252,11 +262,8 @@ fn generate_entry_doc<'a>(
(acc, None)
}
Def::Ability { .. } => todo_abilities!(),
Def::Body(_, _) => (acc, None),
Def::Expect(c) => todo!("documentation for tests {:?}", c),
TypeDef::Ability { .. } => todo_abilities!(),
},
Def::NotYetImplemented(s) => todo!("{}", s),
}

View file

@ -279,11 +279,7 @@ pub struct AbilityMember<'a> {
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Def<'a> {
// TODO in canonicalization, validate the pattern; only certain patterns
// are allowed in annotations.
Annotation(Loc<Pattern<'a>>, Loc<TypeAnnotation<'a>>),
pub enum TypeDef<'a> {
/// A type alias. This is like a standalone annotation, except the pattern
/// must be a capitalized Identifier, e.g.
///
@ -307,6 +303,13 @@ pub enum Def<'a> {
loc_has: Loc<Has<'a>>,
members: &'a [AbilityMember<'a>],
},
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ValueDef<'a> {
// TODO in canonicalization, validate the pattern; only certain patterns
// are allowed in annotations.
Annotation(Loc<Pattern<'a>>, Loc<TypeAnnotation<'a>>),
// TODO in canonicalization, check to see if there are any newlines after the
// annotation; if not, and if it's followed by a Body, then the annotation
@ -323,6 +326,12 @@ pub enum Def<'a> {
},
Expect(&'a Loc<Expr<'a>>),
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Def<'a> {
Type(TypeDef<'a>),
Value(ValueDef<'a>),
// Blank Space (e.g. comments, spaces, newlines) before or after a def.
// We preserve this for the formatter; canonicalization ignores it.
@ -341,6 +350,30 @@ impl<'a> Def<'a> {
debug_assert!(!matches!(def, Def::SpaceBefore(_, _)));
(spaces, def)
}
pub fn unroll_def(&self) -> Result<&TypeDef<'a>, &ValueDef<'a>> {
let mut def = self;
loop {
match def {
Def::Type(type_def) => return Ok(type_def),
Def::Value(value_def) => return Err(value_def),
Def::SpaceBefore(def1, _) | Def::SpaceAfter(def1, _) => def = def1,
Def::NotYetImplemented(s) => todo!("{}", s),
}
}
}
}
impl<'a> From<TypeDef<'a>> for Def<'a> {
fn from(def: TypeDef<'a>) -> Self {
Self::Type(def)
}
}
impl<'a> From<ValueDef<'a>> for Def<'a> {
fn from(def: ValueDef<'a>) -> Self {
Self::Value(def)
}
}
#[derive(Debug, Copy, Clone, PartialEq)]

View file

@ -1,6 +1,6 @@
use crate::ast::{
AssignedField, Collection, CommentOrNewline, Def, Expr, ExtractSpaces, Has, Pattern, Spaceable,
TypeAnnotation, TypeHeader,
TypeAnnotation, TypeDef, TypeHeader, ValueDef,
};
use crate::blankspace::{space0_after_e, space0_around_ee, space0_before_e, space0_e};
use crate::ident::{lowercase_ident, parse_ident, Ident};
@ -576,7 +576,7 @@ fn append_body_definition<'a>(
if spaces.len() <= 1 {
let last = defs.pop();
match last.map(|d| d.value.unroll_spaces_before()) {
Some((before_ann_spaces, Def::Annotation(ann_pattern, ann_type))) => {
Some((before_ann_spaces, Def::Value(ValueDef::Annotation(ann_pattern, ann_type)))) => {
return append_body_definition_help(
arena,
defs,
@ -591,10 +591,10 @@ fn append_body_definition<'a>(
}
Some((
before_ann_spaces,
Def::Alias {
Def::Type(TypeDef::Alias {
header,
ann: ann_type,
},
}),
)) => {
// This is a case like
// UserId x : [ UserId Int ]
@ -628,7 +628,10 @@ fn append_body_definition<'a>(
// the previous and current def can't be joined up
let mut loc_def = Loc::at(
region,
Def::Body(arena.alloc(loc_pattern), &*arena.alloc(loc_def_body)),
Def::Value(ValueDef::Body(
arena.alloc(loc_pattern),
&*arena.alloc(loc_def_body),
)),
);
if !spaces.is_empty() {
@ -660,13 +663,13 @@ fn append_body_definition_help<'a>(
let mut loc_def = Loc::at(
region,
Def::AnnotatedBody {
Def::Value(ValueDef::AnnotatedBody {
ann_pattern: loc_pattern_ann,
ann_type: loc_ann,
comment,
body_pattern: arena.alloc(loc_pattern_body),
body_expr: &*arena.alloc(loc_def_body),
},
}),
);
if !before_ann_spaces.is_empty() {
@ -717,7 +720,10 @@ fn append_annotation_definition<'a>(
kind,
),
_ => {
let mut loc_def = Loc::at(region, Def::Annotation(loc_pattern, loc_ann));
let mut loc_def = Loc::at(
region,
Def::Value(ValueDef::Annotation(loc_pattern, loc_ann)),
);
if !spaces.is_empty() {
loc_def = arena
.alloc(loc_def.value)
@ -736,7 +742,7 @@ fn append_expect_definition<'a>(
spaces: &'a [CommentOrNewline<'a>],
loc_expect_body: Loc<Expr<'a>>,
) {
let def = Def::Expect(arena.alloc(loc_expect_body));
let def: Def = ValueDef::Expect(arena.alloc(loc_expect_body)).into();
let end = loc_expect_body.region.end();
let region = Region::new(start, end);
@ -768,16 +774,16 @@ fn append_type_definition<'a>(
vars: pattern_arguments,
};
let def = match kind {
TypeKind::Alias => Def::Alias {
TypeKind::Alias => TypeDef::Alias {
header,
ann: loc_ann,
},
TypeKind::Opaque => Def::Opaque {
TypeKind::Opaque => TypeDef::Opaque {
header,
typ: loc_ann,
},
};
let mut loc_def = Loc::at(region, def);
let mut loc_def = Loc::at(region, Def::Type(def));
if !spaces.is_empty() {
loc_def = arena
@ -1038,17 +1044,17 @@ fn finish_parsing_alias_or_opaque<'a>(
vars: type_arguments.into_bump_slice(),
};
let type_def = match kind {
TypeKind::Alias => Def::Alias {
TypeKind::Alias => TypeDef::Alias {
header,
ann: ann_type,
},
TypeKind::Opaque => Def::Opaque {
TypeKind::Opaque => TypeDef::Opaque {
header,
typ: ann_type,
},
};
(&*arena.alloc(Loc::at(def_region, type_def)), state)
(&*arena.alloc(Loc::at(def_region, type_def.into())), state)
}
_ => {
@ -1077,9 +1083,9 @@ fn finish_parsing_alias_or_opaque<'a>(
let def_region = Region::span_across(&call.region, &ann_type.region);
let alias = Def::Annotation(Loc::at(expr_region, good), ann_type);
let alias = ValueDef::Annotation(Loc::at(expr_region, good), ann_type);
(&*arena.alloc(Loc::at(def_region, alias)), state)
(&*arena.alloc(Loc::at(def_region, alias.into())), state)
}
}
}
@ -1270,11 +1276,12 @@ fn finish_parsing_ability_def<'a>(
}
let def_region = Region::span_across(&name.region, &demands.last().unwrap().typ.region);
let def = Def::Ability {
let def = TypeDef::Ability {
header: TypeHeader { name, vars: args },
loc_has,
members: demands.into_bump_slice(),
};
}
.into();
let loc_def = &*(arena.alloc(Loc::at(def_region, def)));
Ok((MadeProgress, loc_def, state))
@ -1357,23 +1364,24 @@ fn parse_expr_operator<'a>(
let (loc_def, state) = {
match expr_to_pattern_help(arena, &call.value) {
Ok(good) => {
let (_, mut ann_type, state) = parse_loc_expr(indented_more, arena, state)?;
let (_, mut body, state) = parse_loc_expr(indented_more, arena, state)?;
// put the spaces from after the operator in front of the call
if !spaces_after_operator.is_empty() {
ann_type = arena
.alloc(ann_type.value)
.with_spaces_before(spaces_after_operator, ann_type.region);
body = arena
.alloc(body.value)
.with_spaces_before(spaces_after_operator, body.region);
}
let alias_region = Region::span_across(&call.region, &ann_type.region);
let body_region = Region::span_across(&call.region, &body.region);
let alias = Def::Body(
let alias = ValueDef::Body(
arena.alloc(Loc::at(expr_region, good)),
arena.alloc(ann_type),
);
arena.alloc(body),
)
.into();
(&*arena.alloc(Loc::at(alias_region, alias)), state)
(&*arena.alloc(Loc::at(body_region, alias)), state)
}
Err(_) => {
// this `=` likely occurred inline; treat it as an invalid operator

View file

@ -1,6 +1,7 @@
Defs(
[
@0-36 Ability {
@0-36 Type(
Ability {
header: TypeHeader {
name: @0-4 "Hash",
vars: [],
@ -29,6 +30,7 @@ Defs(
},
],
},
),
],
@38-39 SpaceBefore(
Num(

View file

@ -1,6 +1,7 @@
Defs(
[
@0-45 Ability {
@0-45 Type(
Ability {
header: TypeHeader {
name: @0-4 "Hash",
vars: [],
@ -49,6 +50,7 @@ Defs(
},
],
},
),
],
@47-48 SpaceBefore(
Num(

View file

@ -1,6 +1,7 @@
Defs(
[
@0-37 Ability {
@0-37 Type(
Ability {
header: TypeHeader {
name: @0-4 "Hash",
vars: [],
@ -36,6 +37,7 @@ Defs(
},
],
},
),
],
@39-40 SpaceBefore(
Num(

View file

@ -1,6 +1,7 @@
Defs(
[
@0-33 Ability {
@0-33 Type(
Ability {
header: TypeHeader {
name: @0-3 "Ab1",
vars: [],
@ -35,11 +36,13 @@ Defs(
},
],
},
),
],
@35-71 SpaceBefore(
Defs(
[
@35-68 Ability {
@35-68 Type(
Ability {
header: TypeHeader {
name: @35-38 "Ab2",
vars: [],
@ -74,6 +77,7 @@ Defs(
},
],
},
),
],
@70-71 SpaceBefore(
Num(

View file

@ -1,6 +1,7 @@
Defs(
[
@15-49 AnnotatedBody {
@15-49 Value(
AnnotatedBody {
ann_pattern: @0-8 RecordDestructure(
[
@2-3 Identifier(
@ -48,6 +49,7 @@ Defs(
],
),
},
),
],
@51-52 SpaceBefore(
Var {

View file

@ -1,6 +1,7 @@
Defs(
[
@26-46 AnnotatedBody {
@26-46 Value(
AnnotatedBody {
ann_pattern: @0-8 Apply(
@0-6 GlobalTag(
"UserId",
@ -49,6 +50,7 @@ Defs(
Space,
),
},
),
],
@48-49 SpaceBefore(
Var {

View file

@ -1,7 +1,8 @@
SpaceBefore(
Defs(
[
@107-112 Body(
@107-112 Value(
Body(
@107-108 Identifier(
"x",
),
@ -9,6 +10,7 @@ SpaceBefore(
"5",
),
),
),
],
@114-116 SpaceBefore(
Num(

View file

@ -1,6 +1,7 @@
[
@0-7 SpaceAfter(
SpaceBefore(
Value(
Body(
@0-3 Identifier(
"foo",
@ -9,6 +10,7 @@
"1",
),
),
),
[],
),
[

View file

@ -1,6 +1,7 @@
Defs(
[
@0-36 Body(
@0-36 Value(
Body(
@0-5 Apply(
@0-5 GlobalTag(
"Email",
@ -25,6 +26,7 @@ Defs(
Space,
),
),
),
],
@37-40 SpaceBefore(
Var {

View file

@ -1,6 +1,7 @@
Defs(
[
@0-6 Body(
@0-6 Value(
Body(
@0-4 Identifier(
"iffy",
),
@ -8,6 +9,7 @@ Defs(
"5",
),
),
),
],
@8-10 SpaceBefore(
Num(

View file

@ -1,6 +1,7 @@
Defs(
[
@0-58 Body(
@0-58 Value(
Body(
@0-7 Malformed(
"my_list",
),
@ -62,6 +63,7 @@ Defs(
},
),
),
),
],
@59-61 SpaceBefore(
Num(

View file

@ -1,6 +1,7 @@
Defs(
[
@0-26 Body(
@0-26 Value(
Body(
@0-7 Malformed(
"my_list",
),
@ -30,6 +31,7 @@ Defs(
},
),
),
),
],
@27-29 SpaceBefore(
Num(

View file

@ -1,6 +1,7 @@
Defs(
[
@0-27 Body(
@0-27 Value(
Body(
@0-7 Malformed(
"my_list",
),
@ -30,6 +31,7 @@ Defs(
},
),
),
),
],
@28-30 SpaceBefore(
Num(

View file

@ -1,7 +1,8 @@
SpaceBefore(
Defs(
[
@113-118 Body(
@113-118 Value(
Body(
@113-114 Identifier(
"x",
),
@ -9,6 +10,7 @@ SpaceBefore(
"5",
),
),
),
],
@120-122 SpaceBefore(
Num(

View file

@ -1,6 +1,7 @@
[
@0-24 SpaceAfter(
SpaceBefore(
Value(
Body(
@0-4 Identifier(
"main",
@ -8,7 +9,8 @@
@11-24 SpaceBefore(
Defs(
[
@11-17 Body(
@11-17 Value(
Body(
@11-12 Identifier(
"i",
),
@ -16,6 +18,7 @@
"64",
),
),
),
],
@23-24 SpaceBefore(
Var {
@ -33,6 +36,7 @@
],
),
),
),
[],
),
[

View file

@ -1,6 +1,7 @@
Defs(
[
@0-10 Annotation(
@0-10 Value(
Annotation(
@0-1 Identifier(
"f",
),
@ -14,6 +15,7 @@ Defs(
],
),
),
),
],
@12-14 SpaceBefore(
Num(

View file

@ -1,6 +1,7 @@
Defs(
[
@0-19 Annotation(
@0-19 Value(
Annotation(
@0-1 Identifier(
"f",
),
@ -16,6 +17,7 @@ Defs(
],
),
),
),
],
@21-23 SpaceBefore(
Num(

View file

@ -1,6 +1,7 @@
[
@0-115 SpaceAfter(
SpaceBefore(
Value(
Body(
@0-4 Identifier(
"main",
@ -8,7 +9,8 @@
@11-115 SpaceBefore(
Defs(
[
@43-93 AnnotatedBody {
@43-93 Value(
AnnotatedBody {
ann_pattern: @11-23 Identifier(
"wrappedNotEq",
),
@ -62,6 +64,7 @@
),
),
},
),
],
@99-115 SpaceBefore(
Apply(
@ -90,6 +93,7 @@
],
),
),
),
[],
),
[

View file

@ -1,6 +1,7 @@
Defs(
[
@0-9 Body(
@0-9 Value(
Body(
@0-1 Identifier(
"x",
),
@ -13,6 +14,7 @@ Defs(
],
),
),
),
],
@11-13 SpaceBefore(
Num(

View file

@ -1,6 +1,7 @@
Defs(
[
@0-13 Body(
@0-13 Value(
Body(
@0-1 Identifier(
"x",
),
@ -23,6 +24,7 @@ Defs(
),
),
),
),
],
@15-17 SpaceBefore(
Num(

View file

@ -1,7 +1,8 @@
SpaceBefore(
Defs(
[
@46-51 Body(
@46-51 Value(
Body(
@46-47 Identifier(
"x",
),
@ -9,6 +10,7 @@ SpaceBefore(
"5",
),
),
),
],
@53-55 SpaceBefore(
Num(

View file

@ -1,7 +1,8 @@
SpaceBefore(
Defs(
[
@18-21 Body(
@18-21 Value(
Body(
@18-19 Identifier(
"x",
),
@ -9,6 +10,7 @@ SpaceBefore(
"5",
),
),
),
],
@23-25 SpaceBefore(
Num(

View file

@ -1,7 +1,8 @@
SpaceBefore(
Defs(
[
@18-23 Body(
@18-23 Value(
Body(
@18-19 Identifier(
"x",
),
@ -9,6 +10,7 @@ SpaceBefore(
"5",
),
),
),
],
@25-27 SpaceBefore(
Num(

View file

@ -1,6 +1,7 @@
[
@0-9 SpaceAfter(
SpaceBefore(
Type(
Opaque {
header: TypeHeader {
name: @0-3 "Age",
@ -12,6 +13,7 @@
[],
),
},
),
[],
),
[

View file

@ -1,6 +1,7 @@
[
@0-53 SpaceAfter(
SpaceBefore(
Type(
Opaque {
header: TypeHeader {
name: @0-10 "Bookmark",
@ -41,6 +42,7 @@
ext: None,
},
},
),
[],
),
[

View file

@ -1,6 +1,7 @@
Defs(
[
@0-26 Alias {
@0-26 Type(
Alias {
header: TypeHeader {
name: @0-4 "Blah",
vars: [
@ -25,6 +26,7 @@ Defs(
],
),
},
),
],
@28-30 SpaceBefore(
Num(

View file

@ -1,6 +1,7 @@
Defs(
[
@0-33 Annotation(
@0-33 Value(
Annotation(
@0-3 Identifier(
"foo",
),
@ -31,6 +32,7 @@ Defs(
},
),
),
),
],
@35-37 SpaceBefore(
Num(

View file

@ -1,7 +1,8 @@
SpaceBefore(
Defs(
[
@18-30 Body(
@18-30 Value(
Body(
@18-26 RecordDestructure(
[
@20-21 Identifier(
@ -16,7 +17,9 @@ SpaceBefore(
"5",
),
),
),
@31-36 SpaceBefore(
Value(
Body(
@31-32 Identifier(
"y",
@ -25,6 +28,7 @@ SpaceBefore(
"6",
),
),
),
[
Newline,
],

View file

@ -1,6 +1,7 @@
Defs(
[
@0-122 Annotation(
@0-122 Value(
Annotation(
@0-1 Identifier(
"f",
),
@ -99,6 +100,7 @@ Defs(
],
),
),
),
],
@124-126 SpaceBefore(
Num(

View file

@ -1,5 +1,6 @@
[
@12-19 SpaceBefore(
Value(
Body(
@12-15 Identifier(
"foo",
@ -8,6 +9,7 @@
"1",
),
),
),
[
LineComment(
" comment 1",
@ -15,6 +17,7 @@
],
),
@33-43 SpaceBefore(
Value(
Body(
@33-36 Identifier(
"bar",
@ -25,6 +28,7 @@
),
),
),
),
[
Newline,
Newline,
@ -35,6 +39,7 @@
),
@44-57 SpaceAfter(
SpaceBefore(
Value(
Body(
@44-47 Identifier(
"baz",
@ -45,6 +50,7 @@
),
),
),
),
[
Newline,
],

View file

@ -1,7 +1,8 @@
SpaceBefore(
Defs(
[
@18-23 Body(
@18-23 Value(
Body(
@18-19 Identifier(
"x",
),
@ -9,7 +10,9 @@ SpaceBefore(
"5",
),
),
),
@24-29 SpaceBefore(
Value(
Body(
@24-25 Identifier(
"y",
@ -18,6 +21,7 @@ SpaceBefore(
"6",
),
),
),
[
Newline,
],

View file

@ -1,6 +1,7 @@
Defs(
[
@0-30 Annotation(
@0-30 Value(
Annotation(
@0-7 Identifier(
"doStuff",
),
@ -26,6 +27,7 @@ Defs(
),
),
),
),
],
@31-33 SpaceBefore(
Num(

View file

@ -1,6 +1,7 @@
Defs(
[
@0-27 Annotation(
@0-27 Value(
Annotation(
@0-1 Identifier(
"f",
),
@ -34,6 +35,7 @@ Defs(
],
),
),
),
],
@29-30 SpaceBefore(
Var {

View file

@ -1,6 +1,7 @@
Defs(
[
@0-48 Annotation(
@0-48 Value(
Annotation(
@0-1 Identifier(
"f",
),
@ -50,6 +51,7 @@ Defs(
],
),
),
),
],
@50-51 SpaceBefore(
Var {

View file

@ -1,6 +1,7 @@
Defs(
[
@0-67 Annotation(
@0-67 Value(
Annotation(
@0-1 Identifier(
"f",
),
@ -65,6 +66,7 @@ Defs(
],
),
),
),
],
@69-70 SpaceBefore(
Var {

View file

@ -1,6 +1,7 @@
Defs(
[
@0-15 Annotation(
@0-15 Value(
Annotation(
@0-1 Identifier(
"f",
),
@ -20,6 +21,7 @@ Defs(
],
),
),
),
],
@17-18 SpaceBefore(
Var {

View file

@ -1,6 +1,7 @@
Defs(
[
@0-29 Annotation(
@0-29 Value(
Annotation(
@0-1 Identifier(
"f",
),
@ -34,6 +35,7 @@ Defs(
],
),
),
),
],
@31-32 SpaceBefore(
Var {