mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 05:34:11 +03:00
Replace references to "global tag" with "tag"
This commit is contained in:
parent
470dddc17b
commit
85e7969c2d
@ -245,13 +245,13 @@ pub fn constrain_expr<'a>(
|
||||
exists(arena, field_vars, And(constraints))
|
||||
}
|
||||
}
|
||||
Expr2::GlobalTag {
|
||||
Expr2::Tag {
|
||||
variant_var,
|
||||
ext_var,
|
||||
name,
|
||||
arguments,
|
||||
} => {
|
||||
let tag_name = TagName::Global(name.as_str(env.pool).into());
|
||||
let tag_name = TagName::Tag(name.as_str(env.pool).into());
|
||||
|
||||
constrain_tag(
|
||||
arena,
|
||||
@ -1604,13 +1604,13 @@ pub fn constrain_pattern<'a>(
|
||||
state.constraints.push(whole_con);
|
||||
state.constraints.push(record_con);
|
||||
}
|
||||
GlobalTag {
|
||||
Tag {
|
||||
whole_var,
|
||||
ext_var,
|
||||
tag_name: name,
|
||||
arguments,
|
||||
} => {
|
||||
let tag_name = TagName::Global(name.as_str(env.pool).into());
|
||||
let tag_name = TagName::Tag(name.as_str(env.pool).into());
|
||||
|
||||
constrain_tag_pattern(
|
||||
arena,
|
||||
@ -2198,7 +2198,7 @@ pub mod test_constrain {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn constrain_global_tag() {
|
||||
fn constrain_tag() {
|
||||
infer_eq(
|
||||
indoc!(
|
||||
r#"
|
||||
|
@ -148,7 +148,7 @@ pub enum Expr2 {
|
||||
},
|
||||
|
||||
// Sum Types
|
||||
GlobalTag {
|
||||
Tag {
|
||||
name: PoolStr, // 4B
|
||||
variant_var: Variable, // 4B
|
||||
ext_var: Variable, // 4B
|
||||
|
@ -173,10 +173,10 @@ pub fn expr_to_expr2<'a>(
|
||||
(expr, output)
|
||||
}
|
||||
|
||||
GlobalTag(tag) => {
|
||||
// a global tag without any arguments
|
||||
Tag(tag) => {
|
||||
// a tag without any arguments
|
||||
(
|
||||
Expr2::GlobalTag {
|
||||
Expr2::Tag {
|
||||
name: PoolStr::new(tag, env.pool),
|
||||
variant_var: env.var_store.fresh(),
|
||||
ext_var: env.var_store.fresh(),
|
||||
@ -543,12 +543,12 @@ pub fn expr_to_expr2<'a>(
|
||||
// We can't call a runtime error; bail out by propagating it!
|
||||
return (fn_expr, output);
|
||||
}
|
||||
Expr2::GlobalTag {
|
||||
Expr2::Tag {
|
||||
variant_var,
|
||||
ext_var,
|
||||
name,
|
||||
..
|
||||
} => Expr2::GlobalTag {
|
||||
} => Expr2::Tag {
|
||||
variant_var,
|
||||
ext_var,
|
||||
name,
|
||||
|
@ -41,7 +41,7 @@ pub enum Pattern2 {
|
||||
StrLiteral(PoolStr), // 8B
|
||||
CharacterLiteral(char), // 4B
|
||||
Underscore, // 0B
|
||||
GlobalTag {
|
||||
Tag {
|
||||
whole_var: Variable, // 4B
|
||||
ext_var: Variable, // 4B
|
||||
tag_name: PoolStr, // 8B
|
||||
@ -265,9 +265,9 @@ pub fn to_pattern2<'a>(
|
||||
ptype => unsupported_pattern(env, ptype, region),
|
||||
},
|
||||
|
||||
GlobalTag(name) => {
|
||||
Tag(name) => {
|
||||
// Canonicalize the tag's name.
|
||||
Pattern2::GlobalTag {
|
||||
Pattern2::Tag {
|
||||
whole_var: env.var_store.fresh(),
|
||||
ext_var: env.var_store.fresh(),
|
||||
tag_name: PoolStr::new(name, env.pool),
|
||||
@ -296,7 +296,7 @@ pub fn to_pattern2<'a>(
|
||||
}
|
||||
|
||||
match tag.value {
|
||||
GlobalTag(name) => Pattern2::GlobalTag {
|
||||
Tag(name) => Pattern2::Tag {
|
||||
whole_var: env.var_store.fresh(),
|
||||
ext_var: env.var_store.fresh(),
|
||||
tag_name: PoolStr::new(name, env.pool),
|
||||
@ -479,7 +479,7 @@ pub fn symbols_from_pattern(pool: &Pool, initial: &Pattern2) -> Vec<Symbol> {
|
||||
symbols.push(*symbol);
|
||||
}
|
||||
|
||||
GlobalTag { arguments, .. } => {
|
||||
Tag { arguments, .. } => {
|
||||
for (_, pat_id) in arguments.iter(pool) {
|
||||
let pat = pool.get(*pat_id);
|
||||
stack.push(pat);
|
||||
@ -540,7 +540,7 @@ pub fn symbols_and_variables_from_pattern(
|
||||
symbols.push((*symbol, variable));
|
||||
}
|
||||
|
||||
GlobalTag { arguments, .. } => {
|
||||
Tag { arguments, .. } => {
|
||||
for (var, pat_id) in arguments.iter(pool) {
|
||||
let pat = pool.get(*pat_id);
|
||||
stack.push((*var, pat));
|
||||
|
@ -694,14 +694,14 @@ fn can_tags<'a>(
|
||||
// a duplicate
|
||||
let new_name = 'inner: loop {
|
||||
match tag {
|
||||
Tag::Global { name, args } => {
|
||||
Tag::Apply { name, args } => {
|
||||
let arg_types = PoolVec::with_capacity(args.len() as u32, env.pool);
|
||||
|
||||
for (type_id, loc_arg) in arg_types.iter_node_ids().zip(args.iter()) {
|
||||
as_type_id(env, scope, rigids, type_id, &loc_arg.value, loc_arg.region);
|
||||
}
|
||||
|
||||
let tag_name = TagName::Global(name.value.into());
|
||||
let tag_name = TagName::Tag(name.value.into());
|
||||
tag_types.push((tag_name.clone(), arg_types));
|
||||
|
||||
break 'inner tag_name;
|
||||
|
@ -617,7 +617,7 @@ impl<'a> RemoveSpaces<'a> for Expr<'a> {
|
||||
Expr::Record(a) => Expr::Record(a.remove_spaces(arena)),
|
||||
Expr::Var { module_name, ident } => Expr::Var { module_name, ident },
|
||||
Expr::Underscore(a) => Expr::Underscore(a),
|
||||
Expr::GlobalTag(a) => Expr::GlobalTag(a),
|
||||
Expr::Tag(a) => Expr::Tag(a),
|
||||
Expr::OpaqueRef(a) => Expr::OpaqueRef(a),
|
||||
Expr::Closure(a, b) => Expr::Closure(
|
||||
arena.alloc(a.remove_spaces(arena)),
|
||||
@ -668,7 +668,7 @@ impl<'a> RemoveSpaces<'a> for Pattern<'a> {
|
||||
fn remove_spaces(&self, arena: &'a Bump) -> Self {
|
||||
match *self {
|
||||
Pattern::Identifier(a) => Pattern::Identifier(a),
|
||||
Pattern::GlobalTag(a) => Pattern::GlobalTag(a),
|
||||
Pattern::Tag(a) => Pattern::Tag(a),
|
||||
Pattern::OpaqueRef(a) => Pattern::OpaqueRef(a),
|
||||
Pattern::Apply(a, b) => Pattern::Apply(
|
||||
arena.alloc(a.remove_spaces(arena)),
|
||||
@ -751,7 +751,7 @@ impl<'a> RemoveSpaces<'a> for HasClause<'a> {
|
||||
impl<'a> RemoveSpaces<'a> for Tag<'a> {
|
||||
fn remove_spaces(&self, arena: &'a Bump) -> Self {
|
||||
match *self {
|
||||
Tag::Global { name, args } => Tag::Global {
|
||||
Tag::Apply { name, args } => Tag::Apply {
|
||||
name: name.remove_spaces(arena),
|
||||
args: args.remove_spaces(arena),
|
||||
},
|
||||
|
@ -88,7 +88,7 @@ pub fn expr2_to_markup<'a>(
|
||||
mark_id_ast_id_map,
|
||||
)
|
||||
}
|
||||
Expr2::GlobalTag { name, .. } => new_markup_node(
|
||||
Expr2::Tag { name, .. } => new_markup_node(
|
||||
with_indent(indent_level, &get_string(env, name)),
|
||||
ast_node_id,
|
||||
HighlightStyle::Type,
|
||||
|
@ -69,7 +69,7 @@ xor : Bool, Bool -> Bool
|
||||
##
|
||||
## Structural equality works as follows:
|
||||
##
|
||||
## 1. Global tags are equal if they are the same tag, and also their contents (if any) are equal.
|
||||
## 1. Tags are equal if they have the same tag name, and also their contents (if any) are equal.
|
||||
## 2. Records are equal if all their fields are equal.
|
||||
## 3. Collections ([Str], [List], [Dict], and [Set]) are equal if they are the same length, and also all their corresponding elements are equal.
|
||||
## 4. [Num] values are equal if their numbers are equal, with one exception: if both arguments to `isEq` are *NaN*, then `isEq` returns `False`. See `Num.isNaN` for more about *NaN*.
|
||||
|
@ -131,7 +131,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
|
||||
fn overflow() -> SolvedType {
|
||||
SolvedType::TagUnion(
|
||||
vec![(TagName::Global("Overflow".into()), vec![])],
|
||||
vec![(TagName::Tag("Overflow".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
)
|
||||
}
|
||||
@ -312,7 +312,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
);
|
||||
|
||||
let div_by_zero = SolvedType::TagUnion(
|
||||
vec![(TagName::Global("DivByZero".into()), vec![])],
|
||||
vec![(TagName::Tag("DivByZero".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
|
||||
@ -476,7 +476,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
);
|
||||
|
||||
let out_of_bounds = SolvedType::TagUnion(
|
||||
vec![(TagName::Global("OutOfBounds".into()), vec![])],
|
||||
vec![(TagName::Tag("OutOfBounds".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
|
||||
@ -551,7 +551,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
);
|
||||
|
||||
let out_of_bounds = SolvedType::TagUnion(
|
||||
vec![(TagName::Global("OutOfBounds".into()), vec![])],
|
||||
vec![(TagName::Tag("OutOfBounds".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
|
||||
@ -692,7 +692,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
|
||||
// sqrtChecked : Float a -> Result (Float a) [ SqrtOfNegative ]*
|
||||
let sqrt_of_negative = SolvedType::TagUnion(
|
||||
vec![(TagName::Global("SqrtOfNegative".into()), vec![])],
|
||||
vec![(TagName::Tag("SqrtOfNegative".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
|
||||
@ -711,7 +711,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
|
||||
// logChecked : Float a -> Result (Float a) [ LogNeedsPositive ]*
|
||||
let log_needs_positive = SolvedType::TagUnion(
|
||||
vec![(TagName::Global("LogNeedsPositive".into()), vec![])],
|
||||
vec![(TagName::Tag("LogNeedsPositive".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
|
||||
@ -807,7 +807,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
// bytesToU16 : List U8, Nat -> Result U16 [ OutOfBounds ]
|
||||
{
|
||||
let position_out_of_bounds = SolvedType::TagUnion(
|
||||
vec![(TagName::Global("OutOfBounds".into()), vec![])],
|
||||
vec![(TagName::Tag("OutOfBounds".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
add_top_level_function_type!(
|
||||
@ -820,7 +820,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
// bytesToU32 : List U8, Nat -> Result U32 [ OutOfBounds ]
|
||||
{
|
||||
let position_out_of_bounds = SolvedType::TagUnion(
|
||||
vec![(TagName::Global("OutOfBounds".into()), vec![])],
|
||||
vec![(TagName::Tag("OutOfBounds".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
add_top_level_function_type!(
|
||||
@ -942,7 +942,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
{
|
||||
let bad_utf8 = SolvedType::TagUnion(
|
||||
vec![(
|
||||
TagName::Global("BadUtf8".into()),
|
||||
TagName::Tag("BadUtf8".into()),
|
||||
vec![str_utf8_byte_problem_type(), nat_type()],
|
||||
)],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
@ -960,10 +960,10 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
let bad_utf8 = SolvedType::TagUnion(
|
||||
vec![
|
||||
(
|
||||
TagName::Global("BadUtf8".into()),
|
||||
TagName::Tag("BadUtf8".into()),
|
||||
vec![str_utf8_byte_problem_type(), nat_type()],
|
||||
),
|
||||
(TagName::Global("OutOfBounds".into()), vec![]),
|
||||
(TagName::Tag("OutOfBounds".into()), vec![]),
|
||||
],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
@ -999,7 +999,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
// `str_to_num` in can `builtins.rs`
|
||||
let invalid_str = || {
|
||||
SolvedType::TagUnion(
|
||||
vec![(TagName::Global("InvalidNumStr".into()), vec![])],
|
||||
vec![(TagName::Tag("InvalidNumStr".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
)
|
||||
};
|
||||
@ -1106,7 +1106,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
|
||||
// get : List elem, Nat -> Result elem [ OutOfBounds ]*
|
||||
let index_out_of_bounds = SolvedType::TagUnion(
|
||||
vec![(TagName::Global("OutOfBounds".into()), vec![])],
|
||||
vec![(TagName::Tag("OutOfBounds".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
|
||||
@ -1118,7 +1118,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
|
||||
// first : List elem -> Result elem [ ListWasEmpty ]*
|
||||
let list_was_empty = SolvedType::TagUnion(
|
||||
vec![(TagName::Global("ListWasEmpty".into()), vec![])],
|
||||
vec![(TagName::Tag("ListWasEmpty".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
|
||||
@ -1223,8 +1223,8 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
// [ LT, EQ, GT ]
|
||||
SolvedType::TagUnion(
|
||||
vec![
|
||||
(TagName::Global("Continue".into()), vec![content.clone()]),
|
||||
(TagName::Global("Stop".into()), vec![content]),
|
||||
(TagName::Tag("Continue".into()), vec![content.clone()]),
|
||||
(TagName::Tag("Stop".into()), vec![content]),
|
||||
],
|
||||
Box::new(SolvedType::EmptyTagUnion),
|
||||
)
|
||||
@ -1585,7 +1585,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
// find : List elem, (elem -> Bool) -> Result elem [ NotFound ]*
|
||||
{
|
||||
let not_found = SolvedType::TagUnion(
|
||||
vec![(TagName::Global("NotFound".into()), vec![])],
|
||||
vec![(TagName::Tag("NotFound".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
let (elem, cvar) = (TVAR1, TVAR2);
|
||||
@ -1627,7 +1627,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||
|
||||
// get : Dict k v, k -> Result v [ KeyNotFound ]*
|
||||
let key_not_found = SolvedType::TagUnion(
|
||||
vec![(TagName::Global("KeyNotFound".into()), vec![])],
|
||||
vec![(TagName::Tag("KeyNotFound".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
|
||||
|
@ -365,7 +365,7 @@ pub fn find_type_def_symbols(
|
||||
|
||||
while let Some(tag) = inner_stack.pop() {
|
||||
match tag {
|
||||
Tag::Global { args, .. } => {
|
||||
Tag::Apply { args, .. } => {
|
||||
for t in args.iter() {
|
||||
stack.push(&t.value);
|
||||
}
|
||||
@ -1229,7 +1229,7 @@ fn can_tags<'a>(
|
||||
// a duplicate
|
||||
let new_name = 'inner: loop {
|
||||
match tag {
|
||||
Tag::Global { name, args } => {
|
||||
Tag::Apply { name, args } => {
|
||||
let name = name.value.into();
|
||||
let mut arg_types = Vec::with_capacity(args.len());
|
||||
|
||||
@ -1248,7 +1248,7 @@ fn can_tags<'a>(
|
||||
arg_types.push(ann);
|
||||
}
|
||||
|
||||
let tag_name = TagName::Global(name);
|
||||
let tag_name = TagName::Tag(name);
|
||||
tag_types.push((tag_name.clone(), arg_types));
|
||||
|
||||
break 'inner tag_name;
|
||||
|
@ -4662,7 +4662,7 @@ fn result_map(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
CalledVia::Space,
|
||||
);
|
||||
|
||||
let tag_name = TagName::Global("Ok".into());
|
||||
let tag_name = TagName::Tag("Ok".into());
|
||||
|
||||
// ok branch
|
||||
let ok = Tag {
|
||||
@ -4693,7 +4693,7 @@ fn result_map(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
|
||||
{
|
||||
// err branch
|
||||
let tag_name = TagName::Global("Err".into());
|
||||
let tag_name = TagName::Tag("Err".into());
|
||||
|
||||
let err = Tag {
|
||||
variant_var: var_store.fresh(),
|
||||
@ -4759,7 +4759,7 @@ fn result_map_err(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
CalledVia::Space,
|
||||
);
|
||||
|
||||
let tag_name = TagName::Global("Err".into());
|
||||
let tag_name = TagName::Tag("Err".into());
|
||||
|
||||
// ok branch
|
||||
let ok = Tag {
|
||||
@ -4790,7 +4790,7 @@ fn result_map_err(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
|
||||
{
|
||||
// err branch
|
||||
let tag_name = TagName::Global("Ok".into());
|
||||
let tag_name = TagName::Tag("Ok".into());
|
||||
|
||||
let err = Tag {
|
||||
variant_var: var_store.fresh(),
|
||||
@ -4843,7 +4843,7 @@ fn result_with_default(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
|
||||
{
|
||||
// ok branch
|
||||
let tag_name = TagName::Global("Ok".into());
|
||||
let tag_name = TagName::Tag("Ok".into());
|
||||
|
||||
let pattern = Pattern::AppliedTag {
|
||||
whole_var: result_var,
|
||||
@ -4863,7 +4863,7 @@ fn result_with_default(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
|
||||
{
|
||||
// err branch
|
||||
let tag_name = TagName::Global("Err".into());
|
||||
let tag_name = TagName::Tag("Err".into());
|
||||
|
||||
let pattern = Pattern::AppliedTag {
|
||||
whole_var: result_var,
|
||||
@ -4906,7 +4906,7 @@ fn result_is_err(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
|
||||
{
|
||||
// ok branch
|
||||
let tag_name = TagName::Global("Ok".into());
|
||||
let tag_name = TagName::Tag("Ok".into());
|
||||
|
||||
let pattern = Pattern::AppliedTag {
|
||||
whole_var: result_var,
|
||||
@ -4918,7 +4918,7 @@ fn result_is_err(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
let false_expr = Tag {
|
||||
variant_var: var_store.fresh(),
|
||||
ext_var: var_store.fresh(),
|
||||
name: TagName::Global("False".into()),
|
||||
name: TagName::Tag("False".into()),
|
||||
arguments: vec![],
|
||||
};
|
||||
|
||||
@ -4933,7 +4933,7 @@ fn result_is_err(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
|
||||
{
|
||||
// err branch
|
||||
let tag_name = TagName::Global("Err".into());
|
||||
let tag_name = TagName::Tag("Err".into());
|
||||
|
||||
let pattern = Pattern::AppliedTag {
|
||||
whole_var: result_var,
|
||||
@ -4945,7 +4945,7 @@ fn result_is_err(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
let true_expr = Tag {
|
||||
variant_var: var_store.fresh(),
|
||||
ext_var: var_store.fresh(),
|
||||
name: TagName::Global("True".into()),
|
||||
name: TagName::Tag("True".into()),
|
||||
arguments: vec![],
|
||||
};
|
||||
|
||||
@ -4983,7 +4983,7 @@ fn result_is_ok(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
|
||||
{
|
||||
// ok branch
|
||||
let tag_name = TagName::Global("Ok".into());
|
||||
let tag_name = TagName::Tag("Ok".into());
|
||||
|
||||
let pattern = Pattern::AppliedTag {
|
||||
whole_var: result_var,
|
||||
@ -4995,7 +4995,7 @@ fn result_is_ok(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
let true_expr = Tag {
|
||||
variant_var: var_store.fresh(),
|
||||
ext_var: var_store.fresh(),
|
||||
name: TagName::Global("True".into()),
|
||||
name: TagName::Tag("True".into()),
|
||||
arguments: vec![],
|
||||
};
|
||||
|
||||
@ -5010,7 +5010,7 @@ fn result_is_ok(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
|
||||
{
|
||||
// err branch
|
||||
let tag_name = TagName::Global("Err".into());
|
||||
let tag_name = TagName::Tag("Err".into());
|
||||
|
||||
let pattern = Pattern::AppliedTag {
|
||||
whole_var: result_var,
|
||||
@ -5022,7 +5022,7 @@ fn result_is_ok(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
let false_expr = Tag {
|
||||
variant_var: var_store.fresh(),
|
||||
ext_var: var_store.fresh(),
|
||||
name: TagName::Global("False".into()),
|
||||
name: TagName::Tag("False".into()),
|
||||
arguments: vec![],
|
||||
};
|
||||
|
||||
@ -5073,7 +5073,7 @@ fn result_after(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
CalledVia::Space,
|
||||
);
|
||||
|
||||
let tag_name = TagName::Global("Ok".into());
|
||||
let tag_name = TagName::Tag("Ok".into());
|
||||
|
||||
// ok branch
|
||||
let ok = call_func;
|
||||
@ -5099,7 +5099,7 @@ fn result_after(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
|
||||
{
|
||||
// err branch
|
||||
let tag_name = TagName::Global("Err".into());
|
||||
let tag_name = TagName::Tag("Err".into());
|
||||
|
||||
let err = Tag {
|
||||
variant_var: var_store.fresh(),
|
||||
@ -5157,7 +5157,7 @@ fn tag(name: &'static str, args: Vec<Expr>, var_store: &mut VarStore) -> Expr {
|
||||
Expr::Tag {
|
||||
variant_var: var_store.fresh(),
|
||||
ext_var: var_store.fresh(),
|
||||
name: TagName::Global(name.into()),
|
||||
name: TagName::Tag(name.into()),
|
||||
arguments: args
|
||||
.into_iter()
|
||||
.map(|expr| (var_store.fresh(), no_region(expr)))
|
||||
|
@ -1106,8 +1106,8 @@ fn build_effect_loop(
|
||||
);
|
||||
|
||||
let state_type = {
|
||||
let step_tag_name = TagName::Global("Step".into());
|
||||
let done_tag_name = TagName::Global("Done".into());
|
||||
let step_tag_name = TagName::Tag("Step".into());
|
||||
let done_tag_name = TagName::Tag("Done".into());
|
||||
|
||||
Type::TagUnion(
|
||||
vec![
|
||||
@ -1336,7 +1336,7 @@ fn build_effect_loop_inner_body(
|
||||
let force_thunk2 = force_effect(loop_new_state_step, effect_symbol, thunk2_symbol, var_store);
|
||||
|
||||
let step_branch = {
|
||||
let step_tag_name = TagName::Global("Step".into());
|
||||
let step_tag_name = TagName::Tag("Step".into());
|
||||
|
||||
let step_pattern = applied_tag_pattern(step_tag_name, &[new_state_symbol], var_store);
|
||||
|
||||
@ -1348,7 +1348,7 @@ fn build_effect_loop_inner_body(
|
||||
};
|
||||
|
||||
let done_branch = {
|
||||
let done_tag_name = TagName::Global("Done".into());
|
||||
let done_tag_name = TagName::Tag("Done".into());
|
||||
let done_pattern = applied_tag_pattern(done_tag_name, &[done_symbol], var_store);
|
||||
|
||||
crate::expr::WhenBranch {
|
||||
|
@ -813,7 +813,7 @@ pub fn canonicalize_expr<'a>(
|
||||
}),
|
||||
Output::default(),
|
||||
),
|
||||
ast::Expr::GlobalTag(tag) => {
|
||||
ast::Expr::Tag(tag) => {
|
||||
let variant_var = var_store.fresh();
|
||||
let ext_var = var_store.fresh();
|
||||
|
||||
@ -821,7 +821,7 @@ pub fn canonicalize_expr<'a>(
|
||||
|
||||
(
|
||||
ZeroArgumentTag {
|
||||
name: TagName::Global((*tag).into()),
|
||||
name: TagName::Tag((*tag).into()),
|
||||
variant_var,
|
||||
closure_name: symbol,
|
||||
ext_var,
|
||||
|
@ -150,7 +150,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Loc<Expr<'a>>) -> &'a Loc
|
||||
| MalformedIdent(_, _)
|
||||
| MalformedClosure
|
||||
| PrecedenceConflict { .. }
|
||||
| GlobalTag(_)
|
||||
| Tag(_)
|
||||
| OpaqueRef(_) => loc_expr,
|
||||
|
||||
Access(sub_expr, paths) => {
|
||||
|
@ -260,12 +260,12 @@ pub fn canonicalize_pattern<'a>(
|
||||
Pattern::Shadowed(original_region, shadow, new_symbol)
|
||||
}
|
||||
},
|
||||
GlobalTag(name) => {
|
||||
Tag(name) => {
|
||||
// Canonicalize the tag's name.
|
||||
Pattern::AppliedTag {
|
||||
whole_var: var_store.fresh(),
|
||||
ext_var: var_store.fresh(),
|
||||
tag_name: TagName::Global((*name).into()),
|
||||
tag_name: TagName::Tag((*name).into()),
|
||||
arguments: vec![],
|
||||
}
|
||||
}
|
||||
@ -294,8 +294,8 @@ pub fn canonicalize_pattern<'a>(
|
||||
}
|
||||
|
||||
match tag.value {
|
||||
GlobalTag(name) => {
|
||||
let tag_name = TagName::Global(name.into());
|
||||
Tag(name) => {
|
||||
let tag_name = TagName::Tag(name.into());
|
||||
Pattern::AppliedTag {
|
||||
whole_var: var_store.fresh(),
|
||||
ext_var: var_store.fresh(),
|
||||
|
@ -468,7 +468,7 @@ impl<'a> Formattable for Tag<'a> {
|
||||
use self::Tag::*;
|
||||
|
||||
match self {
|
||||
Global { args, .. } => args.iter().any(|arg| (&arg.value).is_multiline()),
|
||||
Apply { args, .. } => args.iter().any(|arg| (&arg.value).is_multiline()),
|
||||
Tag::SpaceBefore(_, _) | Tag::SpaceAfter(_, _) => true,
|
||||
Malformed(text) => text.chars().any(|c| c == '\n'),
|
||||
}
|
||||
@ -484,7 +484,7 @@ impl<'a> Formattable for Tag<'a> {
|
||||
let is_multiline = self.is_multiline();
|
||||
|
||||
match self {
|
||||
Tag::Global { name, args } => {
|
||||
Tag::Apply { name, args } => {
|
||||
buf.indent(indent);
|
||||
buf.push_str(name.value);
|
||||
if is_multiline {
|
||||
|
@ -37,7 +37,7 @@ impl<'a> Formattable for Expr<'a> {
|
||||
| Underscore { .. }
|
||||
| MalformedIdent(_, _)
|
||||
| MalformedClosure
|
||||
| GlobalTag(_)
|
||||
| Tag(_)
|
||||
| OpaqueRef(_) => false,
|
||||
|
||||
// These expressions always have newlines
|
||||
@ -272,7 +272,7 @@ impl<'a> Formattable for Expr<'a> {
|
||||
buf.indent(indent);
|
||||
buf.push_str(string);
|
||||
}
|
||||
GlobalTag(string) | OpaqueRef(string) => {
|
||||
Tag(string) | OpaqueRef(string) => {
|
||||
buf.indent(indent);
|
||||
buf.push_str(string)
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ impl<'a> Formattable for Pattern<'a> {
|
||||
Pattern::OptionalField(_, expr) => expr.is_multiline(),
|
||||
|
||||
Pattern::Identifier(_)
|
||||
| Pattern::GlobalTag(_)
|
||||
| Pattern::Tag(_)
|
||||
| Pattern::OpaqueRef(_)
|
||||
| Pattern::Apply(_, _)
|
||||
| Pattern::NumLiteral(..)
|
||||
@ -57,7 +57,7 @@ impl<'a> Formattable for Pattern<'a> {
|
||||
buf.indent(indent);
|
||||
buf.push_str(string)
|
||||
}
|
||||
GlobalTag(name) | OpaqueRef(name) => {
|
||||
Tag(name) | OpaqueRef(name) => {
|
||||
buf.indent(indent);
|
||||
buf.push_str(name);
|
||||
}
|
||||
|
@ -913,7 +913,7 @@ trait Backend<'a> {
|
||||
TagName::Closure(sym) => {
|
||||
self.set_last_seen(*sym, stmt);
|
||||
}
|
||||
TagName::Global(_) => {}
|
||||
TagName::Tag(_) => {}
|
||||
}
|
||||
for sym in *arguments {
|
||||
self.set_last_seen(*sym, stmt);
|
||||
|
@ -373,7 +373,7 @@ fn record_field_to_doc(
|
||||
// The Option here represents if it is malformed.
|
||||
fn tag_to_doc(in_func_ann: bool, tag: ast::Tag) -> Option<Tag> {
|
||||
match tag {
|
||||
ast::Tag::Global { name, args } => Some(Tag {
|
||||
ast::Tag::Apply { name, args } => Some(Tag {
|
||||
name: name.value.to_string(),
|
||||
values: {
|
||||
let mut type_vars = Vec::new();
|
||||
|
@ -4837,8 +4837,8 @@ fn default_aliases() -> roc_solve::solve::Aliases {
|
||||
|
||||
let typ = Type::TagUnion(
|
||||
vec![
|
||||
(TagName::Global("Ok".into()), vec![Type::Variable(tvar1)]),
|
||||
(TagName::Global("Err".into()), vec![Type::Variable(tvar2)]),
|
||||
(TagName::Tag("Ok".into()), vec![Type::Variable(tvar1)]),
|
||||
(TagName::Tag("Err".into()), vec![Type::Variable(tvar2)]),
|
||||
],
|
||||
TypeExtension::Closed,
|
||||
);
|
||||
|
@ -44,14 +44,14 @@ pub type TagIdIntType = u16;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub enum TagName {
|
||||
/// Global tags have no module, but tend to be short strings (since they're
|
||||
/// Tags have no module, but tend to be short strings (since they're
|
||||
/// never qualified), so we store them as ident strings.
|
||||
///
|
||||
/// This is allows canonicalization to happen in parallel without locks.
|
||||
/// If global tags had a Symbol representation, then each module would have to
|
||||
/// deal with contention on a global mutex around translating global tag strings
|
||||
/// If tags had a Symbol representation, then each module would have to
|
||||
/// deal with contention on a global mutex around translating tag strings
|
||||
/// into integers. (Record field labels work the same way, for the same reason.)
|
||||
Global(Uppercase),
|
||||
Tag(Uppercase),
|
||||
|
||||
/// Used to connect the closure size to the function it corresponds to
|
||||
Closure(Symbol),
|
||||
@ -64,7 +64,7 @@ roc_error_macros::assert_sizeof_default!(TagName, 24);
|
||||
impl TagName {
|
||||
pub fn as_ident_str(&self, interns: &Interns, home: ModuleId) -> IdentStr {
|
||||
match self {
|
||||
TagName::Global(uppercase) => uppercase.as_ident_str().clone(),
|
||||
TagName::Tag(uppercase) => uppercase.as_ident_str().clone(),
|
||||
TagName::Closure(symbol) => {
|
||||
symbol.fully_qualified(interns, home).as_ident_str().clone()
|
||||
}
|
||||
|
@ -1048,9 +1048,9 @@ define_builtins! {
|
||||
2 BOOL: "Bool" => {
|
||||
0 BOOL_BOOL: "Bool" // the Bool.Bool type alias
|
||||
1 BOOL_FALSE: "False" imported // Bool.Bool = [ False, True ]
|
||||
// NB: not strictly needed; used for finding global tag names in error suggestions
|
||||
// NB: not strictly needed; used for finding tag names in error suggestions
|
||||
2 BOOL_TRUE: "True" imported // Bool.Bool = [ False, True ]
|
||||
// NB: not strictly needed; used for finding global tag names in error suggestions
|
||||
// NB: not strictly needed; used for finding tag names in error suggestions
|
||||
3 BOOL_AND: "and"
|
||||
4 BOOL_OR: "or"
|
||||
5 BOOL_NOT: "not"
|
||||
@ -1157,9 +1157,9 @@ define_builtins! {
|
||||
5 RESULT: "Result" => {
|
||||
0 RESULT_RESULT: "Result" // the Result.Result type alias
|
||||
1 RESULT_OK: "Ok" imported // Result.Result a e = [ Ok a, Err e ]
|
||||
// NB: not strictly needed; used for finding global tag names in error suggestions
|
||||
// NB: not strictly needed; used for finding tag names in error suggestions
|
||||
2 RESULT_ERR: "Err" imported // Result.Result a e = [ Ok a, Err e ]
|
||||
// NB: not strictly needed; used for finding global tag names in error suggestions
|
||||
// NB: not strictly needed; used for finding tag names in error suggestions
|
||||
3 RESULT_MAP: "map"
|
||||
4 RESULT_MAP_ERR: "mapErr"
|
||||
5 RESULT_WITH_DEFAULT: "withDefault"
|
||||
|
@ -512,7 +512,7 @@ fn test_at_path<'a>(
|
||||
render_as: RenderAs::Tag,
|
||||
alternatives: vec![Ctor {
|
||||
tag_id: TagId(0),
|
||||
name: CtorName::Tag(TagName::Global(RECORD_TAG_NAME.into())),
|
||||
name: CtorName::Tag(TagName::Tag(RECORD_TAG_NAME.into())),
|
||||
arity: destructs.len(),
|
||||
}],
|
||||
};
|
||||
@ -532,7 +532,7 @@ fn test_at_path<'a>(
|
||||
|
||||
IsCtor {
|
||||
tag_id: 0,
|
||||
ctor_name: CtorName::Tag(TagName::Global(RECORD_TAG_NAME.into())),
|
||||
ctor_name: CtorName::Tag(TagName::Tag(RECORD_TAG_NAME.into())),
|
||||
union,
|
||||
arguments,
|
||||
}
|
||||
@ -685,7 +685,7 @@ fn to_relevant_branch_help<'a>(
|
||||
tag_id,
|
||||
..
|
||||
} => {
|
||||
debug_assert!(test_name == &CtorName::Tag(TagName::Global(RECORD_TAG_NAME.into())));
|
||||
debug_assert!(test_name == &CtorName::Tag(TagName::Tag(RECORD_TAG_NAME.into())));
|
||||
let sub_positions = destructs.into_iter().enumerate().map(|(index, destruct)| {
|
||||
let pattern = match destruct.typ {
|
||||
DestructType::Guard(guard) => guard.clone(),
|
||||
|
@ -45,7 +45,7 @@ fn simplify(pattern: &crate::ir::Pattern) -> Pattern {
|
||||
let union = Union {
|
||||
render_as: RenderAs::Record(field_names),
|
||||
alternatives: vec![Ctor {
|
||||
name: CtorName::Tag(TagName::Global("#Record".into())),
|
||||
name: CtorName::Tag(TagName::Tag("#Record".into())),
|
||||
tag_id,
|
||||
arity: destructures.len(),
|
||||
}],
|
||||
@ -169,7 +169,7 @@ fn to_nonredundant_rows(
|
||||
render_as: RenderAs::Guard,
|
||||
alternatives: vec![Ctor {
|
||||
tag_id,
|
||||
name: CtorName::Tag(TagName::Global("#Guard".into())),
|
||||
name: CtorName::Tag(TagName::Tag("#Guard".into())),
|
||||
arity: 2,
|
||||
}],
|
||||
};
|
||||
|
@ -1655,7 +1655,7 @@ impl<'a> Expr<'a> {
|
||||
..
|
||||
} => {
|
||||
let doc_tag = match tag_name {
|
||||
TagName::Global(s) => alloc.text(s.as_str()),
|
||||
TagName::Tag(s) => alloc.text(s.as_str()),
|
||||
TagName::Closure(s) => alloc
|
||||
.text("ClosureTag(")
|
||||
.append(symbol_to_doc(alloc, *s))
|
||||
@ -1676,7 +1676,7 @@ impl<'a> Expr<'a> {
|
||||
..
|
||||
} => {
|
||||
let doc_tag = match tag_name {
|
||||
TagName::Global(s) => alloc.text(s.as_str()),
|
||||
TagName::Tag(s) => alloc.text(s.as_str()),
|
||||
TagName::Closure(s) => alloc
|
||||
.text("ClosureTag(")
|
||||
.append(symbol_to_doc(alloc, *s))
|
||||
|
@ -343,7 +343,7 @@ impl LambdaSet {
|
||||
TagName::Closure(symbol) => {
|
||||
layouts.symbols.push(*symbol);
|
||||
}
|
||||
TagName::Global(_) => unreachable!("lambda set tags must be closure tags"),
|
||||
TagName::Tag(_) => unreachable!("lambda set tags must be closure tags"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ pub enum Expr<'a> {
|
||||
Underscore(&'a str),
|
||||
|
||||
// Tags
|
||||
GlobalTag(&'a str),
|
||||
Tag(&'a str),
|
||||
|
||||
// Reference to an opaque type, e.g. @Opaq
|
||||
OpaqueRef(&'a str),
|
||||
@ -439,7 +439,7 @@ pub enum TypeAnnotation<'a> {
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Tag<'a> {
|
||||
Global {
|
||||
Apply {
|
||||
name: Loc<&'a str>,
|
||||
args: &'a [Loc<TypeAnnotation<'a>>],
|
||||
},
|
||||
@ -515,7 +515,7 @@ pub enum Pattern<'a> {
|
||||
// Identifier
|
||||
Identifier(&'a str),
|
||||
|
||||
GlobalTag(&'a str),
|
||||
Tag(&'a str),
|
||||
|
||||
OpaqueRef(&'a str),
|
||||
|
||||
@ -570,7 +570,7 @@ pub enum Base {
|
||||
impl<'a> Pattern<'a> {
|
||||
pub fn from_ident(arena: &'a Bump, ident: Ident<'a>) -> Pattern<'a> {
|
||||
match ident {
|
||||
Ident::GlobalTag(string) => Pattern::GlobalTag(string),
|
||||
Ident::Tag(string) => Pattern::Tag(string),
|
||||
Ident::OpaqueRef(string) => Pattern::OpaqueRef(string),
|
||||
Ident::Access { module_name, parts } => {
|
||||
if parts.len() == 1 {
|
||||
@ -619,7 +619,7 @@ impl<'a> Pattern<'a> {
|
||||
|
||||
match (self, other) {
|
||||
(Identifier(x), Identifier(y)) => x == y,
|
||||
(GlobalTag(x), GlobalTag(y)) => x == y,
|
||||
(Tag(x), Tag(y)) => x == y,
|
||||
(Apply(constructor_x, args_x), Apply(constructor_y, args_y)) => {
|
||||
let equivalent_args = args_x
|
||||
.iter()
|
||||
@ -917,7 +917,7 @@ impl<'a> Expr<'a> {
|
||||
}
|
||||
|
||||
pub fn is_tag(&self) -> bool {
|
||||
matches!(self, Expr::GlobalTag(_))
|
||||
matches!(self, Expr::Tag(_))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -604,7 +604,7 @@ fn append_body_definition<'a>(
|
||||
// UserId x = UserId 42
|
||||
// We optimistically parsed the first line as an alias; we now turn it
|
||||
// into an annotation.
|
||||
let loc_name = arena.alloc(header.name.map(|x| Pattern::GlobalTag(x)));
|
||||
let loc_name = arena.alloc(header.name.map(|x| Pattern::Tag(x)));
|
||||
let ann_pattern = Pattern::Apply(loc_name, header.vars);
|
||||
let vars_region = Region::across_all(header.vars.iter().map(|v| &v.region));
|
||||
let region_ann_pattern = Region::span_across(&loc_name.region, &vars_region);
|
||||
@ -698,7 +698,7 @@ fn append_annotation_definition<'a>(
|
||||
match &loc_pattern.value {
|
||||
Pattern::Apply(
|
||||
Loc {
|
||||
value: Pattern::GlobalTag(name),
|
||||
value: Pattern::Tag(name),
|
||||
..
|
||||
},
|
||||
alias_arguments,
|
||||
@ -712,7 +712,7 @@ fn append_annotation_definition<'a>(
|
||||
loc_ann,
|
||||
kind,
|
||||
),
|
||||
Pattern::GlobalTag(name) => append_type_definition(
|
||||
Pattern::Tag(name) => append_type_definition(
|
||||
arena,
|
||||
defs,
|
||||
region,
|
||||
@ -873,12 +873,12 @@ fn parse_defs_end<'a>(
|
||||
{
|
||||
Pattern::Apply(
|
||||
Loc {
|
||||
value: Pattern::GlobalTag(name),
|
||||
value: Pattern::Tag(name),
|
||||
region,
|
||||
},
|
||||
args,
|
||||
) => Some((name, *region, args)),
|
||||
Pattern::GlobalTag(name) => Some((name, loc_pattern.region, &[])),
|
||||
Pattern::Tag(name) => Some((name, loc_pattern.region, &[])),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
@ -1020,7 +1020,7 @@ fn finish_parsing_alias_or_opaque<'a>(
|
||||
.map_err(|fail| (MadeProgress, fail, state.clone()))?;
|
||||
|
||||
let (loc_def, state) = match &expr.value {
|
||||
Expr::GlobalTag(name) => {
|
||||
Expr::Tag(name) => {
|
||||
let mut type_arguments = Vec::with_capacity_in(arguments.len(), arena);
|
||||
|
||||
for argument in arguments {
|
||||
@ -1543,11 +1543,11 @@ fn parse_expr_end<'a>(
|
||||
..
|
||||
},
|
||||
state,
|
||||
)) if matches!(expr_state.expr.value, Expr::GlobalTag(..)) => {
|
||||
)) if matches!(expr_state.expr.value, Expr::Tag(..)) => {
|
||||
// This is an ability definition, `Ability arg1 ... has ...`.
|
||||
|
||||
let name = expr_state.expr.map_owned(|e| match e {
|
||||
Expr::GlobalTag(name) => name,
|
||||
Expr::Tag(name) => name,
|
||||
_ => unreachable!(),
|
||||
});
|
||||
|
||||
@ -1763,7 +1763,7 @@ fn expr_to_pattern_help<'a>(arena: &'a Bump, expr: &Expr<'a>) -> Result<Pattern<
|
||||
}
|
||||
}
|
||||
Expr::Underscore(opt_name) => Ok(Pattern::Underscore(opt_name)),
|
||||
Expr::GlobalTag(value) => Ok(Pattern::GlobalTag(value)),
|
||||
Expr::Tag(value) => Ok(Pattern::Tag(value)),
|
||||
Expr::OpaqueRef(value) => Ok(Pattern::OpaqueRef(value)),
|
||||
Expr::Apply(loc_val, loc_args, _) => {
|
||||
let region = loc_val.region;
|
||||
@ -2436,7 +2436,7 @@ where
|
||||
|
||||
fn ident_to_expr<'a>(arena: &'a Bump, src: Ident<'a>) -> Expr<'a> {
|
||||
match src {
|
||||
Ident::GlobalTag(string) => Expr::GlobalTag(string),
|
||||
Ident::Tag(string) => Expr::Tag(string),
|
||||
Ident::OpaqueRef(string) => Expr::OpaqueRef(string),
|
||||
Ident::Access { module_name, parts } => {
|
||||
let mut iter = parts.iter();
|
||||
|
@ -5,7 +5,7 @@ use bumpalo::collections::vec::Vec;
|
||||
use bumpalo::Bump;
|
||||
use roc_region::all::Position;
|
||||
|
||||
/// A global tag, for example. Must start with an uppercase letter
|
||||
/// A tag, for example. Must start with an uppercase letter
|
||||
/// and then contain only letters and numbers afterwards - no dots allowed!
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub struct UppercaseIdent<'a>(&'a str);
|
||||
@ -35,7 +35,7 @@ impl<'a> From<&'a UppercaseIdent<'a>> for &'a str {
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Ident<'a> {
|
||||
/// Foo or Bar
|
||||
GlobalTag(&'a str),
|
||||
Tag(&'a str),
|
||||
/// @Foo or @Bar
|
||||
OpaqueRef(&'a str),
|
||||
/// foo or foo.bar or Foo.Bar.baz.qux
|
||||
@ -54,7 +54,7 @@ impl<'a> Ident<'a> {
|
||||
use self::Ident::*;
|
||||
|
||||
match self {
|
||||
GlobalTag(string) | OpaqueRef(string) => string.len(),
|
||||
Tag(string) | OpaqueRef(string) => string.len(),
|
||||
Access { module_name, parts } => {
|
||||
let mut len = if module_name.is_empty() {
|
||||
0
|
||||
@ -105,7 +105,7 @@ pub fn tag_name<'a>() -> impl Parser<'a, &'a str, ()> {
|
||||
///
|
||||
/// * A module name
|
||||
/// * A type name
|
||||
/// * A global tag
|
||||
/// * A tag
|
||||
pub fn uppercase<'a>() -> impl Parser<'a, UppercaseIdent<'a>, ()> {
|
||||
move |_, state: State<'a>| match chomp_uppercase_part(state.bytes()) {
|
||||
Err(progress) => Err((progress, (), state)),
|
||||
@ -120,7 +120,7 @@ pub fn uppercase<'a>() -> impl Parser<'a, UppercaseIdent<'a>, ()> {
|
||||
///
|
||||
/// * A module name
|
||||
/// * A type name
|
||||
/// * A global tag
|
||||
/// * A tag
|
||||
pub fn uppercase_ident<'a>() -> impl Parser<'a, &'a str, ()> {
|
||||
move |_, state: State<'a>| match chomp_uppercase_part(state.bytes()) {
|
||||
Err(progress) => Err((progress, (), state)),
|
||||
@ -418,9 +418,9 @@ fn chomp_identifier_chain<'a>(
|
||||
BadIdent::Underscore(pos.bump_column(chomped as u32 + 1)),
|
||||
))
|
||||
} else if first_is_uppercase {
|
||||
// just one segment, starting with an uppercase letter; that's a global tag
|
||||
// just one segment, starting with an uppercase letter; that's a tag
|
||||
let value = unsafe { std::str::from_utf8_unchecked(&buffer[..chomped]) };
|
||||
Ok((chomped as u32, Ident::GlobalTag(value)))
|
||||
Ok((chomped as u32, Ident::Tag(value)))
|
||||
} else {
|
||||
// just one segment, starting with a lowercase letter; that's a normal identifier
|
||||
let value = unsafe { std::str::from_utf8_unchecked(&buffer[..chomped]) };
|
||||
|
@ -213,10 +213,10 @@ fn loc_ident_pattern_help<'a>(
|
||||
specialize(|_, pos| EPattern::Start(pos), loc!(parse_ident)).parse(arena, state)?;
|
||||
|
||||
match loc_ident.value {
|
||||
Ident::GlobalTag(tag) => {
|
||||
Ident::Tag(tag) => {
|
||||
let loc_tag = Loc {
|
||||
region: loc_ident.region,
|
||||
value: Pattern::GlobalTag(tag),
|
||||
value: Pattern::Tag(tag),
|
||||
};
|
||||
|
||||
// Make sure `Foo Bar 1` is parsed as `Foo (Bar) 1`, and not `Foo (Bar 1)`
|
||||
|
@ -214,7 +214,7 @@ fn tag_type<'a>(min_indent: u32) -> impl Parser<'a, Tag<'a>, ETypeTagUnion<'a>>
|
||||
let (_, args, state) = specialize_ref(ETypeTagUnion::Type, loc_applied_args_e(min_indent))
|
||||
.parse(arena, state)?;
|
||||
|
||||
let result = Tag::Global {
|
||||
let result = Tag::Apply {
|
||||
name,
|
||||
args: args.into_bump_slice(),
|
||||
};
|
||||
|
@ -3,7 +3,7 @@ Defs(
|
||||
@26-46 Value(
|
||||
AnnotatedBody {
|
||||
ann_pattern: @0-8 Apply(
|
||||
@0-6 GlobalTag(
|
||||
@0-6 Tag(
|
||||
"UserId",
|
||||
),
|
||||
[
|
||||
@ -15,7 +15,7 @@ Defs(
|
||||
ann_type: @11-25 TagUnion {
|
||||
ext: None,
|
||||
tags: [
|
||||
@13-23 Global {
|
||||
@13-23 Apply {
|
||||
name: @13-19 "UserId",
|
||||
args: [
|
||||
@20-23 Apply(
|
||||
@ -29,7 +29,7 @@ Defs(
|
||||
},
|
||||
comment: None,
|
||||
body_pattern: @26-34 Apply(
|
||||
@26-32 GlobalTag(
|
||||
@26-32 Tag(
|
||||
"UserId",
|
||||
),
|
||||
[
|
||||
@ -39,7 +39,7 @@ Defs(
|
||||
],
|
||||
),
|
||||
body_expr: @37-46 Apply(
|
||||
@37-43 GlobalTag(
|
||||
@37-43 Tag(
|
||||
"UserId",
|
||||
),
|
||||
[
|
||||
|
@ -1,5 +1,5 @@
|
||||
Apply(
|
||||
@0-4 GlobalTag(
|
||||
@0-4 Tag(
|
||||
"Whee",
|
||||
),
|
||||
[
|
@ -1,5 +1,5 @@
|
||||
Apply(
|
||||
@0-4 GlobalTag(
|
||||
@0-4 Tag(
|
||||
"Whee",
|
||||
),
|
||||
[
|
@ -1,3 +1,3 @@
|
||||
GlobalTag(
|
||||
Tag(
|
||||
"Whee",
|
||||
)
|
@ -3,7 +3,7 @@ Defs(
|
||||
@0-36 Value(
|
||||
Body(
|
||||
@0-5 Apply(
|
||||
@0-5 GlobalTag(
|
||||
@0-5 Tag(
|
||||
"Email",
|
||||
),
|
||||
[
|
||||
@ -13,7 +13,7 @@ Defs(
|
||||
],
|
||||
),
|
||||
@12-36 Apply(
|
||||
@12-17 GlobalTag(
|
||||
@12-17 Tag(
|
||||
"Email",
|
||||
),
|
||||
[
|
||||
|
@ -1,12 +1,12 @@
|
||||
When(
|
||||
@5-22 Apply(
|
||||
@5-11 GlobalTag(
|
||||
@5-11 Tag(
|
||||
"Delmin",
|
||||
),
|
||||
[
|
||||
@13-19 ParensAround(
|
||||
Apply(
|
||||
@13-16 GlobalTag(
|
||||
@13-16 Tag(
|
||||
"Del",
|
||||
),
|
||||
[
|
||||
@ -29,12 +29,12 @@ When(
|
||||
patterns: [
|
||||
@30-48 SpaceBefore(
|
||||
Apply(
|
||||
@30-36 GlobalTag(
|
||||
@30-36 Tag(
|
||||
"Delmin",
|
||||
),
|
||||
[
|
||||
@38-44 Apply(
|
||||
@38-41 GlobalTag(
|
||||
@38-41 Tag(
|
||||
"Del",
|
||||
),
|
||||
[
|
||||
@ -54,17 +54,17 @@ When(
|
||||
),
|
||||
],
|
||||
value: @52-73 Apply(
|
||||
@52-56 GlobalTag(
|
||||
@52-56 Tag(
|
||||
"Node",
|
||||
),
|
||||
[
|
||||
@57-62 GlobalTag(
|
||||
@57-62 Tag(
|
||||
"Black",
|
||||
),
|
||||
@63-64 Num(
|
||||
"0",
|
||||
),
|
||||
@65-70 GlobalTag(
|
||||
@65-70 Tag(
|
||||
"False",
|
||||
),
|
||||
@71-73 Var {
|
||||
|
@ -10,7 +10,7 @@ BinOps(
|
||||
@4-25 If(
|
||||
[
|
||||
(
|
||||
@7-11 GlobalTag(
|
||||
@7-11 Tag(
|
||||
"True",
|
||||
),
|
||||
@17-18 Num(
|
||||
|
@ -6,7 +6,7 @@ Record(
|
||||
@5-26 If(
|
||||
[
|
||||
(
|
||||
@8-12 GlobalTag(
|
||||
@8-12 Tag(
|
||||
"True",
|
||||
),
|
||||
@18-19 Num(
|
||||
|
@ -1,6 +1,6 @@
|
||||
Closure(
|
||||
[
|
||||
@1-6 GlobalTag(
|
||||
@1-6 Tag(
|
||||
"Thing",
|
||||
),
|
||||
],
|
||||
|
@ -50,7 +50,7 @@ When(
|
||||
WhenBranch {
|
||||
patterns: [
|
||||
@54-56 SpaceBefore(
|
||||
GlobalTag(
|
||||
Tag(
|
||||
"Ok",
|
||||
),
|
||||
[
|
||||
|
@ -8,7 +8,7 @@ ParensAround(
|
||||
WhenBranch {
|
||||
patterns: [
|
||||
@15-17 SpaceBefore(
|
||||
GlobalTag(
|
||||
Tag(
|
||||
"Ok",
|
||||
),
|
||||
[
|
||||
|
@ -9,7 +9,7 @@ ParensAround(
|
||||
WhenBranch {
|
||||
patterns: [
|
||||
@15-17 SpaceBefore(
|
||||
GlobalTag(
|
||||
Tag(
|
||||
"Ok",
|
||||
),
|
||||
[
|
||||
|
@ -132,8 +132,8 @@ mod test_parse {
|
||||
pass/add_with_spaces.expr,
|
||||
pass/annotated_record_destructure.expr,
|
||||
pass/annotated_tag_destructure.expr,
|
||||
pass/apply_global_tag.expr,
|
||||
pass/apply_parenthetical_global_tag_args.expr,
|
||||
pass/apply_tag.expr,
|
||||
pass/apply_parenthetical_tag_args.expr,
|
||||
pass/apply_three_args.expr,
|
||||
pass/apply_two_args.expr,
|
||||
pass/apply_unary_negation.expr,
|
||||
@ -141,7 +141,7 @@ mod test_parse {
|
||||
pass/basic_apply.expr,
|
||||
pass/basic_docs.expr,
|
||||
pass/basic_field.expr,
|
||||
pass/basic_global_tag.expr,
|
||||
pass/basic_tag.expr,
|
||||
pass/basic_var.expr,
|
||||
pass/closure_with_underscores.expr,
|
||||
pass/comment_after_def.module,
|
||||
@ -233,7 +233,7 @@ mod test_parse {
|
||||
pass/positive_int.expr,
|
||||
pass/provides_type.header,
|
||||
pass/qualified_field.expr,
|
||||
pass/qualified_global_tag.expr,
|
||||
pass/qualified_tag.expr,
|
||||
pass/qualified_var.expr,
|
||||
pass/record_destructure_def.expr,
|
||||
pass/record_func_type_decl.expr,
|
||||
@ -654,17 +654,17 @@ mod test_parse {
|
||||
// }
|
||||
|
||||
// #[test]
|
||||
// fn ann_global_open_union() {
|
||||
// fn ann_open_union() {
|
||||
// let arena = Bump::new();
|
||||
// let newline = bumpalo::vec![in &arena; Newline];
|
||||
// let newlines = bumpalo::vec![in &arena; Newline, Newline];
|
||||
// let tag1 = Tag::Global {
|
||||
// let tag1 = Tag::Apply {
|
||||
// name: Located::new(0, 0, 8, 12, "True"),
|
||||
// args: &[],
|
||||
// };
|
||||
// let tag2arg = Located::new(0, 0, 22, 27, TypeAnnotation::Apply("", "Thing", &[]));
|
||||
// let tag2args = bumpalo::vec![in &arena; tag2arg];
|
||||
// let tag2 = Tag::Global {
|
||||
// let tag2 = Tag::Apply {
|
||||
// name: Located::new(0, 0, 14, 21, "Perhaps"),
|
||||
// args: tag2args.into_bump_slice(),
|
||||
// };
|
||||
@ -683,7 +683,7 @@ mod test_parse {
|
||||
// );
|
||||
// let def = Def::Body(
|
||||
// arena.alloc(Located::new(1, 1, 0, 3, Identifier("foo"))),
|
||||
// arena.alloc(Located::new(1, 1, 6, 10, Expr::GlobalTag("True"))),
|
||||
// arena.alloc(Located::new(1, 1, 6, 10, Expr::Tag("True"))),
|
||||
// );
|
||||
// let spaced_def = Def::SpaceBefore(arena.alloc(def), newline.into_bump_slice());
|
||||
// let loc_def = &*arena.alloc(Located::new(1, 1, 0, 10, spaced_def));
|
||||
@ -708,17 +708,17 @@ mod test_parse {
|
||||
// }
|
||||
|
||||
// #[test]
|
||||
// fn ann_global_closed_union() {
|
||||
// fn ann_closed_union() {
|
||||
// let arena = Bump::new();
|
||||
// let newline = bumpalo::vec![in &arena; Newline];
|
||||
// let newlines = bumpalo::vec![in &arena; Newline, Newline];
|
||||
// let tag1 = Tag::Global {
|
||||
// let tag1 = Tag::Apply {
|
||||
// name: Located::new(0, 0, 8, 12, "True"),
|
||||
// args: &[],
|
||||
// };
|
||||
// let tag2arg = Located::new(0, 0, 22, 27, TypeAnnotation::Apply("", "Thing", &[]));
|
||||
// let tag2args = bumpalo::vec![in &arena; tag2arg];
|
||||
// let tag2 = Tag::Global {
|
||||
// let tag2 = Tag::Apply {
|
||||
// name: Located::new(0, 0, 14, 21, "Perhaps"),
|
||||
// args: tag2args.into_bump_slice(),
|
||||
// };
|
||||
@ -736,7 +736,7 @@ mod test_parse {
|
||||
// );
|
||||
// let def = Def::Body(
|
||||
// arena.alloc(Located::new(1, 1, 0, 3, Identifier("foo"))),
|
||||
// arena.alloc(Located::new(1, 1, 6, 10, Expr::GlobalTag("True"))),
|
||||
// arena.alloc(Located::new(1, 1, 6, 10, Expr::Tag("True"))),
|
||||
// );
|
||||
// let spaced_def = Def::SpaceBefore(arena.alloc(def), newline.into_bump_slice());
|
||||
// let loc_def = &*arena.alloc(Located::new(1, 1, 0, 10, spaced_def));
|
||||
|
@ -2048,7 +2048,7 @@ fn insert_tags_fast_path<'a>(
|
||||
tags: &'a [(TagName, Vec<Type>)],
|
||||
stack: &mut bumpalo::collections::Vec<'_, TypeToVar<'a>>,
|
||||
) -> UnionTags {
|
||||
if let [(TagName::Global(tag_name), arguments)] = tags {
|
||||
if let [(TagName::Tag(tag_name), arguments)] = tags {
|
||||
let variable_slice = register_tag_arguments(subs, rank, pools, arena, stack, arguments);
|
||||
let new_variable_slices =
|
||||
SubsSlice::extend_new(&mut subs.variable_slices, [variable_slice]);
|
||||
|
@ -185,7 +185,7 @@ mod solve_expr {
|
||||
fn promote_expr_to_module(src: &str) -> String {
|
||||
let mut buffer = String::from(indoc!(
|
||||
r#"
|
||||
app "test"
|
||||
app "test"
|
||||
imports []
|
||||
provides [ main ] to "./platform"
|
||||
|
||||
@ -1588,7 +1588,7 @@ mod solve_expr {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn global_tag_with_field() {
|
||||
fn tag_with_field() {
|
||||
infer_eq(
|
||||
indoc!(
|
||||
r#"
|
||||
@ -4177,7 +4177,7 @@ mod solve_expr {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn double_tag_application_pattern_global() {
|
||||
fn double_tag_application_pattern() {
|
||||
infer_eq_without_problem(
|
||||
indoc!(
|
||||
r#"
|
||||
|
@ -955,8 +955,8 @@ pub fn bool_type() -> SolvedType {
|
||||
fn bool_alias_content() -> SolvedType {
|
||||
SolvedType::TagUnion(
|
||||
vec![
|
||||
(TagName::Global("False".into()), vec![]),
|
||||
(TagName::Global("True".into()), vec![]),
|
||||
(TagName::Tag("False".into()), vec![]),
|
||||
(TagName::Tag("True".into()), vec![]),
|
||||
],
|
||||
Box::new(SolvedType::EmptyTagUnion),
|
||||
)
|
||||
@ -967,9 +967,9 @@ pub fn ordering_type() -> SolvedType {
|
||||
// [ LT, EQ, GT ]
|
||||
SolvedType::TagUnion(
|
||||
vec![
|
||||
(TagName::Global("EQ".into()), vec![]),
|
||||
(TagName::Global("GT".into()), vec![]),
|
||||
(TagName::Global("LT".into()), vec![]),
|
||||
(TagName::Tag("EQ".into()), vec![]),
|
||||
(TagName::Tag("GT".into()), vec![]),
|
||||
(TagName::Tag("LT".into()), vec![]),
|
||||
],
|
||||
Box::new(SolvedType::EmptyTagUnion),
|
||||
)
|
||||
@ -995,8 +995,8 @@ pub fn box_type(a: SolvedType) -> SolvedType {
|
||||
fn result_alias_content(a: SolvedType, e: SolvedType) -> SolvedType {
|
||||
SolvedType::TagUnion(
|
||||
vec![
|
||||
(TagName::Global("Err".into()), vec![e]),
|
||||
(TagName::Global("Ok".into()), vec![a]),
|
||||
(TagName::Tag("Err".into()), vec![e]),
|
||||
(TagName::Tag("Ok".into()), vec![a]),
|
||||
],
|
||||
Box::new(SolvedType::EmptyTagUnion),
|
||||
)
|
||||
@ -1056,12 +1056,12 @@ pub fn str_utf8_byte_problem_alias_content() -> SolvedType {
|
||||
// [ CodepointTooLarge, EncodesSurrogateHalf, OverlongEncoding, InvalidStartByte, UnexpectedEndOfSequence, ExpectedContinuation ]
|
||||
SolvedType::TagUnion(
|
||||
vec![
|
||||
(TagName::Global("CodepointTooLarge".into()), vec![]),
|
||||
(TagName::Global("EncodesSurrogateHalf".into()), vec![]),
|
||||
(TagName::Global("ExpectedContinuation".into()), vec![]),
|
||||
(TagName::Global("InvalidStartByte".into()), vec![]),
|
||||
(TagName::Global("OverlongEncoding".into()), vec![]),
|
||||
(TagName::Global("UnexpectedEndOfSequence".into()), vec![]),
|
||||
(TagName::Tag("CodepointTooLarge".into()), vec![]),
|
||||
(TagName::Tag("EncodesSurrogateHalf".into()), vec![]),
|
||||
(TagName::Tag("ExpectedContinuation".into()), vec![]),
|
||||
(TagName::Tag("InvalidStartByte".into()), vec![]),
|
||||
(TagName::Tag("OverlongEncoding".into()), vec![]),
|
||||
(TagName::Tag("UnexpectedEndOfSequence".into()), vec![]),
|
||||
],
|
||||
Box::new(SolvedType::EmptyTagUnion),
|
||||
)
|
||||
|
@ -203,7 +203,7 @@ impl Subs {
|
||||
|
||||
for tag_name in tag_names {
|
||||
let serialized = match tag_name {
|
||||
TagName::Global(uppercase) => {
|
||||
TagName::Tag(uppercase) => {
|
||||
let slice = SubsSlice::extend_new(
|
||||
&mut buf,
|
||||
uppercase.as_str().as_bytes().iter().copied(),
|
||||
@ -350,7 +350,7 @@ impl Subs {
|
||||
offset += bytes.len();
|
||||
let string = unsafe { std::str::from_utf8_unchecked(bytes) };
|
||||
|
||||
TagName::Global(string.into())
|
||||
TagName::Tag(string.into())
|
||||
}
|
||||
SerializedTagName::Closure(symbol) => TagName::Closure(*symbol),
|
||||
};
|
||||
@ -400,7 +400,7 @@ pub struct TagNameCache {
|
||||
impl TagNameCache {
|
||||
pub fn get_mut(&mut self, tag_name: &TagName) -> Option<&mut SubsSlice<TagName>> {
|
||||
match tag_name {
|
||||
TagName::Global(uppercase) => {
|
||||
TagName::Tag(uppercase) => {
|
||||
// force into block
|
||||
match self.globals.iter().position(|u| u == uppercase) {
|
||||
Some(index) => Some(&mut self.globals_slices[index]),
|
||||
@ -416,7 +416,7 @@ impl TagNameCache {
|
||||
|
||||
pub fn push(&mut self, tag_name: &TagName, slice: SubsSlice<TagName>) {
|
||||
match tag_name {
|
||||
TagName::Global(uppercase) => {
|
||||
TagName::Tag(uppercase) => {
|
||||
self.globals.push(uppercase.clone());
|
||||
self.globals_slices.push(slice);
|
||||
}
|
||||
@ -642,7 +642,7 @@ impl SubsSlice<TagName> {
|
||||
let start = subs.tag_names.len() as u32;
|
||||
|
||||
subs.tag_names
|
||||
.extend(std::iter::repeat(TagName::Global(Uppercase::default())).take(length));
|
||||
.extend(std::iter::repeat(TagName::Tag(Uppercase::default())).take(length));
|
||||
|
||||
Self::new(start, length as u16)
|
||||
}
|
||||
@ -1477,12 +1477,12 @@ impl Subs {
|
||||
|
||||
let mut tag_names = Vec::with_capacity(32);
|
||||
|
||||
tag_names.push(TagName::Global("Err".into()));
|
||||
tag_names.push(TagName::Global("Ok".into()));
|
||||
tag_names.push(TagName::Tag("Err".into()));
|
||||
tag_names.push(TagName::Tag("Ok".into()));
|
||||
|
||||
tag_names.push(TagName::Global("InvalidNumStr".into()));
|
||||
tag_names.push(TagName::Global("BadUtf8".into()));
|
||||
tag_names.push(TagName::Global("OutOfBounds".into()));
|
||||
tag_names.push(TagName::Tag("InvalidNumStr".into()));
|
||||
tag_names.push(TagName::Tag("BadUtf8".into()));
|
||||
tag_names.push(TagName::Tag("OutOfBounds".into()));
|
||||
|
||||
let mut subs = Subs {
|
||||
utable: UnificationTable::default(),
|
||||
@ -1522,8 +1522,8 @@ impl Subs {
|
||||
let bool_union_tags = UnionTags::insert_into_subs(
|
||||
&mut subs,
|
||||
[
|
||||
(TagName::Global("False".into()), []),
|
||||
(TagName::Global("True".into()), []),
|
||||
(TagName::Tag("False".into()), []),
|
||||
(TagName::Tag("True".into()), []),
|
||||
],
|
||||
);
|
||||
|
||||
@ -2211,10 +2211,10 @@ impl UnionTags {
|
||||
slice.length == 1
|
||||
}
|
||||
|
||||
pub fn is_newtype_wrapper_of_global_tag(&self, subs: &Subs) -> bool {
|
||||
pub fn is_newtype_wrapper_of_tag(&self, subs: &Subs) -> bool {
|
||||
self.is_newtype_wrapper(subs) && {
|
||||
let tags = &subs.tag_names[self.tag_names().indices()];
|
||||
matches!(tags[0], TagName::Global(_))
|
||||
matches!(tags[0], TagName::Tag(_))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -844,8 +844,8 @@ fn markdown_to_html(
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok((_, Ident::GlobalTag(type_name), _)) => {
|
||||
// This looks like a global tag name, but it could
|
||||
Ok((_, Ident::Tag(type_name), _)) => {
|
||||
// This looks like a tag name, but it could
|
||||
// be a type alias that's in scope, e.g. [I64]
|
||||
let DocUrl { url, title } = doc_url(
|
||||
loaded_module.module_id,
|
||||
|
@ -100,7 +100,7 @@ fn unroll_newtypes_and_aliases<'a>(
|
||||
loop {
|
||||
match content {
|
||||
Content::Structure(FlatType::TagUnion(tags, _))
|
||||
if tags.is_newtype_wrapper_of_global_tag(env.subs) =>
|
||||
if tags.is_newtype_wrapper_of_tag(env.subs) =>
|
||||
{
|
||||
let (tag_name, vars): (&TagName, &[Variable]) = tags
|
||||
.unsorted_iterator(env.subs, Variable::EMPTY_TAG_UNION)
|
||||
@ -471,7 +471,7 @@ fn jit_to_ast_help<'a, A: ReplApp<'a>>(
|
||||
|
||||
fn tag_name_to_expr<'a>(env: &Env<'a, '_>, tag_name: &TagName) -> Expr<'a> {
|
||||
match tag_name {
|
||||
TagName::Global(_) => Expr::GlobalTag(
|
||||
TagName::Tag(_) => Expr::Tag(
|
||||
env.arena
|
||||
.alloc_str(&tag_name.as_ident_str(env.interns, env.home)),
|
||||
),
|
||||
@ -1048,7 +1048,7 @@ fn bool_to_ast<'a, M: ReplAppMemory>(
|
||||
|
||||
let loc_tag_expr = {
|
||||
let tag_name = &tag_name.as_ident_str(env.interns, env.home);
|
||||
let tag_expr = Expr::GlobalTag(arena.alloc_str(tag_name));
|
||||
let tag_expr = Expr::Tag(arena.alloc_str(tag_name));
|
||||
|
||||
&*arena.alloc(Loc {
|
||||
value: tag_expr,
|
||||
@ -1127,7 +1127,7 @@ fn byte_to_ast<'a, M: ReplAppMemory>(
|
||||
|
||||
let loc_tag_expr = {
|
||||
let tag_name = &tag_name.as_ident_str(env.interns, env.home);
|
||||
let tag_expr = Expr::GlobalTag(arena.alloc_str(tag_name));
|
||||
let tag_expr = Expr::Tag(arena.alloc_str(tag_name));
|
||||
|
||||
&*arena.alloc(Loc {
|
||||
value: tag_expr,
|
||||
|
@ -1255,7 +1255,7 @@ fn pretty_runtime_error<'b>(
|
||||
}
|
||||
QualifiedIdentifier => alloc
|
||||
.tip()
|
||||
.append(alloc.reflow("In patterns, only global tags can be qualified")),
|
||||
.append(alloc.reflow("In patterns, only tags can be qualified")),
|
||||
};
|
||||
|
||||
doc = alloc.stack([
|
||||
|
@ -165,7 +165,7 @@ fn pattern_to_doc_help<'b>(
|
||||
// #Guard <fake-condition-tag> <unexhausted-pattern>
|
||||
debug_assert!(union.alternatives[tag_id.0 as usize]
|
||||
.name
|
||||
.is_tag(&TagName::Global("#Guard".into())),);
|
||||
.is_tag(&TagName::Tag("#Guard".into())),);
|
||||
debug_assert!(args.len() == 2);
|
||||
let tag = pattern_to_doc_help(alloc, args[1].clone(), in_type_param);
|
||||
alloc.concat([
|
||||
|
@ -637,9 +637,9 @@ fn to_expr_report<'b>(
|
||||
alloc.reflow(" condition to evaluate to a "),
|
||||
alloc.type_str("Bool"),
|
||||
alloc.reflow("—either "),
|
||||
alloc.global_tag_name("True".into()),
|
||||
alloc.tag("True".into()),
|
||||
alloc.reflow(" or "),
|
||||
alloc.global_tag_name("False".into()),
|
||||
alloc.tag("False".into()),
|
||||
alloc.reflow("."),
|
||||
]),
|
||||
// Note: Elm has a hint here about truthiness. I think that
|
||||
@ -676,9 +676,9 @@ fn to_expr_report<'b>(
|
||||
alloc.reflow(" condition to evaluate to a "),
|
||||
alloc.type_str("Bool"),
|
||||
alloc.reflow("—either "),
|
||||
alloc.global_tag_name("True".into()),
|
||||
alloc.tag("True".into()),
|
||||
alloc.reflow(" or "),
|
||||
alloc.global_tag_name("False".into()),
|
||||
alloc.tag("False".into()),
|
||||
alloc.reflow("."),
|
||||
]),
|
||||
// Note: Elm has a hint here about truthiness. I think that
|
||||
@ -714,9 +714,9 @@ fn to_expr_report<'b>(
|
||||
alloc.reflow(" guard condition to evaluate to a "),
|
||||
alloc.type_str("Bool"),
|
||||
alloc.reflow("—either "),
|
||||
alloc.global_tag_name("True".into()),
|
||||
alloc.tag("True".into()),
|
||||
alloc.reflow(" or "),
|
||||
alloc.global_tag_name("False".into()),
|
||||
alloc.tag("False".into()),
|
||||
alloc.reflow("."),
|
||||
]),
|
||||
)
|
||||
@ -1435,29 +1435,29 @@ fn format_category<'b>(
|
||||
),
|
||||
|
||||
TagApply {
|
||||
tag_name: TagName::Global(name),
|
||||
tag_name: TagName::Tag(name),
|
||||
args_count: 0,
|
||||
} => (
|
||||
alloc.concat([
|
||||
alloc.text(format!("{}his ", t)),
|
||||
alloc.global_tag_name(name.to_owned()),
|
||||
alloc.tag(name.to_owned()),
|
||||
if name.as_str() == "True" || name.as_str() == "False" {
|
||||
alloc.text(" boolean")
|
||||
} else {
|
||||
alloc.text(" global tag")
|
||||
alloc.text(" tag")
|
||||
},
|
||||
]),
|
||||
alloc.text(" has the type:"),
|
||||
),
|
||||
|
||||
TagApply {
|
||||
tag_name: TagName::Global(name),
|
||||
tag_name: TagName::Tag(name),
|
||||
args_count: _,
|
||||
} => (
|
||||
alloc.concat([
|
||||
alloc.text(format!("{}his ", t)),
|
||||
alloc.global_tag_name(name.to_owned()),
|
||||
alloc.text(" global tag application"),
|
||||
alloc.tag(name.to_owned()),
|
||||
alloc.text(" tag application"),
|
||||
]),
|
||||
alloc.text(" has the type:"),
|
||||
),
|
||||
|
@ -385,7 +385,7 @@ impl<'a> RocDocAllocator<'a> {
|
||||
|
||||
pub fn tag_name(&'a self, tn: TagName) -> DocBuilder<'a, Self, Annotation> {
|
||||
match tn {
|
||||
TagName::Global(uppercase) => self.global_tag_name(uppercase),
|
||||
TagName::Tag(uppercase) => self.tag(uppercase),
|
||||
TagName::Closure(_symbol) => unreachable!("closure tags are internal only"),
|
||||
}
|
||||
}
|
||||
@ -417,9 +417,9 @@ impl<'a> RocDocAllocator<'a> {
|
||||
.annotate(Annotation::Symbol)
|
||||
}
|
||||
|
||||
pub fn global_tag_name(&'a self, uppercase: Uppercase) -> DocBuilder<'a, Self, Annotation> {
|
||||
pub fn tag(&'a self, uppercase: Uppercase) -> DocBuilder<'a, Self, Annotation> {
|
||||
self.text(format!("{}", uppercase))
|
||||
.annotate(Annotation::GlobalTag)
|
||||
.annotate(Annotation::Tag)
|
||||
}
|
||||
|
||||
pub fn opaque_name(&'a self, opaque: Symbol) -> DocBuilder<'a, Self, Annotation> {
|
||||
@ -790,7 +790,7 @@ pub enum Annotation {
|
||||
Emphasized,
|
||||
Url,
|
||||
Keyword,
|
||||
GlobalTag,
|
||||
Tag,
|
||||
RecordField,
|
||||
TypeVariable,
|
||||
Alias,
|
||||
@ -882,7 +882,7 @@ where
|
||||
Url => {
|
||||
self.write_str("<")?;
|
||||
}
|
||||
GlobalTag | Keyword | RecordField | Symbol | Typo | TypoSuggestion | TypeVariable
|
||||
Tag | Keyword | RecordField | Symbol | Typo | TypoSuggestion | TypeVariable
|
||||
if !self.in_type_block && !self.in_code_block =>
|
||||
{
|
||||
self.write_str("`")?;
|
||||
@ -912,8 +912,7 @@ where
|
||||
Url => {
|
||||
self.write_str(">")?;
|
||||
}
|
||||
GlobalTag | Keyword | RecordField | Symbol | Typo | TypoSuggestion
|
||||
| TypeVariable
|
||||
Tag | Keyword | RecordField | Symbol | Typo | TypoSuggestion | TypeVariable
|
||||
if !self.in_type_block && !self.in_code_block =>
|
||||
{
|
||||
self.write_str("`")?;
|
||||
@ -1005,7 +1004,7 @@ where
|
||||
ParserSuggestion => {
|
||||
self.write_str(self.palette.parser_suggestion)?;
|
||||
}
|
||||
TypeBlock | GlobalTag | RecordField => { /* nothing yet */ }
|
||||
TypeBlock | Tag | RecordField => { /* nothing yet */ }
|
||||
}
|
||||
self.style_stack.push(*annotation);
|
||||
Ok(())
|
||||
@ -1023,7 +1022,7 @@ where
|
||||
self.write_str(self.palette.reset)?;
|
||||
}
|
||||
|
||||
TypeBlock | GlobalTag | Opaque | RecordField => { /* nothing yet */ }
|
||||
TypeBlock | Tag | Opaque | RecordField => { /* nothing yet */ }
|
||||
},
|
||||
}
|
||||
Ok(())
|
||||
|
@ -1408,7 +1408,7 @@ mod test_reporting {
|
||||
4│ f Blue
|
||||
^^^^
|
||||
|
||||
This `Blue` global tag has the type:
|
||||
This `Blue` tag has the type:
|
||||
|
||||
[ Blue ]a
|
||||
|
||||
@ -1446,7 +1446,7 @@ mod test_reporting {
|
||||
4│ f (Blue 3.14)
|
||||
^^^^^^^^^
|
||||
|
||||
This `Blue` global tag application has the type:
|
||||
This `Blue` tag application has the type:
|
||||
|
||||
[ Blue (Float a) ]b
|
||||
|
||||
@ -2179,7 +2179,7 @@ mod test_reporting {
|
||||
2│ f = \_ -> Foo
|
||||
^^^
|
||||
|
||||
This `Foo` global tag has the type:
|
||||
This `Foo` tag has the type:
|
||||
|
||||
[ Foo ]a
|
||||
|
||||
@ -2306,7 +2306,7 @@ mod test_reporting {
|
||||
5│ Ok
|
||||
^^
|
||||
|
||||
This `Ok` global tag has the type:
|
||||
This `Ok` tag has the type:
|
||||
|
||||
[ Ok ]a
|
||||
|
||||
@ -3630,7 +3630,7 @@ mod test_reporting {
|
||||
4│ x = Cons {} (Cons "foo" Nil)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This `Cons` global tag application has the type:
|
||||
This `Cons` tag application has the type:
|
||||
|
||||
[ Cons {} [ Cons Str [ Cons {} a, Nil ] as a, Nil ], Nil ]
|
||||
|
||||
@ -3671,7 +3671,7 @@ mod test_reporting {
|
||||
5│ x = ACons 0 (BCons 1 (ACons "foo" BNil ))
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This `ACons` global tag application has the type:
|
||||
This `ACons` tag application has the type:
|
||||
|
||||
[ ACons (Num (Integer Signed64)) [
|
||||
BCons (Num (Integer Signed64)) [ ACons Str [ BCons I64 a, BNil ],
|
||||
@ -4456,7 +4456,7 @@ mod test_reporting {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn qualified_global_tag() {
|
||||
fn qualified_tag() {
|
||||
report_problem_as(
|
||||
indoc!(
|
||||
r#"
|
||||
@ -7141,7 +7141,7 @@ I need all branches in an `if` to have the same type!
|
||||
6│ isEmpty (Name "boo")
|
||||
^^^^^^^^^^
|
||||
|
||||
This `Name` global tag application has the type:
|
||||
This `Name` tag application has the type:
|
||||
|
||||
[ Name Str ]a
|
||||
|
||||
@ -7341,7 +7341,7 @@ I need all branches in an `if` to have the same type!
|
||||
5│ Job { inputs }
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
This `Job` global tag application has the type:
|
||||
This `Job` tag application has the type:
|
||||
|
||||
[ Job { inputs : List Str } ]
|
||||
|
||||
@ -9676,7 +9676,7 @@ I need all branches in an `if` to have the same type!
|
||||
15│ notYet: hash (A 1),
|
||||
^^^
|
||||
|
||||
This `A` global tag application has the type:
|
||||
This `A` tag application has the type:
|
||||
|
||||
[ A (Num a) ]b
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user