mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
remove ATTR_ATTR usage
This commit is contained in:
parent
fa7dec2997
commit
62da85cc06
7 changed files with 37 additions and 265 deletions
|
@ -2103,17 +2103,6 @@ fn build_specialized_proc_from_var<'a>(
|
||||||
ret_var,
|
ret_var,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Content::Structure(FlatType::Apply(Symbol::ATTR_ATTR, args))
|
|
||||||
if !pattern_symbols.is_empty() =>
|
|
||||||
{
|
|
||||||
build_specialized_proc_from_var(
|
|
||||||
env,
|
|
||||||
layout_cache,
|
|
||||||
proc_name,
|
|
||||||
pattern_symbols,
|
|
||||||
args[1],
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Content::Alias(_, _, actual) => build_specialized_proc_from_var(
|
Content::Alias(_, _, actual) => build_specialized_proc_from_var(
|
||||||
env,
|
env,
|
||||||
layout_cache,
|
layout_cache,
|
||||||
|
@ -7142,12 +7131,6 @@ pub fn num_argument_to_int_or_float(
|
||||||
| Content::Alias(Symbol::NUM_AT_UNSIGNED8, _, _) => {
|
| Content::Alias(Symbol::NUM_AT_UNSIGNED8, _, _) => {
|
||||||
IntOrFloat::UnsignedIntType(IntPrecision::I8)
|
IntOrFloat::UnsignedIntType(IntPrecision::I8)
|
||||||
}
|
}
|
||||||
Content::Structure(FlatType::Apply(Symbol::ATTR_ATTR, attr_args)) => {
|
|
||||||
debug_assert!(attr_args.len() == 2);
|
|
||||||
|
|
||||||
// Recurse on the second argument
|
|
||||||
num_argument_to_int_or_float(subs, ptr_bytes, attr_args[1], false)
|
|
||||||
}
|
|
||||||
Content::Alias(Symbol::NUM_FLOATINGPOINT, args, _) => {
|
Content::Alias(Symbol::NUM_FLOATINGPOINT, args, _) => {
|
||||||
debug_assert!(args.len() == 1);
|
debug_assert!(args.len() == 1);
|
||||||
|
|
||||||
|
|
|
@ -1454,9 +1454,6 @@ pub fn union_sorted_tags<'a>(
|
||||||
fn get_recursion_var(subs: &Subs, var: Variable) -> Option<Variable> {
|
fn get_recursion_var(subs: &Subs, var: Variable) -> Option<Variable> {
|
||||||
match subs.get_without_compacting(var).content {
|
match subs.get_without_compacting(var).content {
|
||||||
Content::Structure(FlatType::RecursiveTagUnion(rec_var, _, _)) => Some(rec_var),
|
Content::Structure(FlatType::RecursiveTagUnion(rec_var, _, _)) => Some(rec_var),
|
||||||
Content::Structure(FlatType::Apply(Symbol::ATTR_ATTR, args)) => {
|
|
||||||
get_recursion_var(subs, args[1])
|
|
||||||
}
|
|
||||||
Content::Alias(_, _, actual) => get_recursion_var(subs, actual),
|
Content::Alias(_, _, actual) => get_recursion_var(subs, actual),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
@ -1820,18 +1817,6 @@ fn layout_from_num_content<'a>(content: Content) -> Result<Layout<'a>, LayoutPro
|
||||||
|
|
||||||
fn unwrap_num_tag<'a>(subs: &Subs, var: Variable) -> Result<Layout<'a>, LayoutProblem> {
|
fn unwrap_num_tag<'a>(subs: &Subs, var: Variable) -> Result<Layout<'a>, LayoutProblem> {
|
||||||
match subs.get_without_compacting(var).content {
|
match subs.get_without_compacting(var).content {
|
||||||
Content::Structure(flat_type) => match flat_type {
|
|
||||||
FlatType::Apply(Symbol::ATTR_ATTR, args) => {
|
|
||||||
debug_assert_eq!(args.len(), 2);
|
|
||||||
|
|
||||||
let arg_var = args.get(1).unwrap();
|
|
||||||
|
|
||||||
unwrap_num_tag(subs, *arg_var)
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
todo!("TODO handle Num.@Num flat_type {:?}", flat_type);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Content::Alias(Symbol::NUM_INTEGER, args, _) => {
|
Content::Alias(Symbol::NUM_INTEGER, args, _) => {
|
||||||
debug_assert!(args.len() == 1);
|
debug_assert!(args.len() == 1);
|
||||||
|
|
||||||
|
@ -1908,37 +1893,20 @@ fn dict_layout_from_key_value<'a>(
|
||||||
value_var: Variable,
|
value_var: Variable,
|
||||||
) -> Result<Layout<'a>, LayoutProblem> {
|
) -> Result<Layout<'a>, LayoutProblem> {
|
||||||
match env.subs.get_without_compacting(key_var).content {
|
match env.subs.get_without_compacting(key_var).content {
|
||||||
Content::Structure(FlatType::Apply(Symbol::ATTR_ATTR, key_args)) => {
|
|
||||||
debug_assert_eq!(key_args.len(), 2);
|
|
||||||
|
|
||||||
let var = *key_args.get(1).unwrap();
|
|
||||||
|
|
||||||
dict_layout_from_key_value(env, var, value_var)
|
|
||||||
}
|
|
||||||
Content::FlexVar(_) | Content::RigidVar(_) => {
|
Content::FlexVar(_) | Content::RigidVar(_) => {
|
||||||
// If this was still a (Dict * *) then it must have been an empty dict
|
// If this was still a (Dict * *) then it must have been an empty dict
|
||||||
Ok(Layout::Builtin(Builtin::EmptyDict))
|
Ok(Layout::Builtin(Builtin::EmptyDict))
|
||||||
}
|
}
|
||||||
key_content => {
|
key_content => {
|
||||||
match env.subs.get_without_compacting(value_var).content {
|
let value_content = env.subs.get_without_compacting(value_var).content;
|
||||||
Content::Structure(FlatType::Apply(Symbol::ATTR_ATTR, value_args)) => {
|
let key_layout = Layout::new_help(env, key_var, key_content)?;
|
||||||
debug_assert_eq!(value_args.len(), 2);
|
let value_layout = Layout::new_help(env, value_var, value_content)?;
|
||||||
|
|
||||||
let var = *value_args.get(1).unwrap();
|
// This is a normal list.
|
||||||
|
Ok(Layout::Builtin(Builtin::Dict(
|
||||||
dict_layout_from_key_value(env, key_var, var)
|
env.arena.alloc(key_layout),
|
||||||
}
|
env.arena.alloc(value_layout),
|
||||||
value_content => {
|
)))
|
||||||
let key_layout = Layout::new_help(env, key_var, key_content)?;
|
|
||||||
let value_layout = Layout::new_help(env, value_var, value_content)?;
|
|
||||||
|
|
||||||
// This is a normal list.
|
|
||||||
Ok(Layout::Builtin(Builtin::Dict(
|
|
||||||
env.arena.alloc(key_layout),
|
|
||||||
env.arena.alloc(value_layout),
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1948,13 +1916,6 @@ pub fn list_layout_from_elem<'a>(
|
||||||
elem_var: Variable,
|
elem_var: Variable,
|
||||||
) -> Result<Layout<'a>, LayoutProblem> {
|
) -> Result<Layout<'a>, LayoutProblem> {
|
||||||
match env.subs.get_without_compacting(elem_var).content {
|
match env.subs.get_without_compacting(elem_var).content {
|
||||||
Content::Structure(FlatType::Apply(Symbol::ATTR_ATTR, args)) => {
|
|
||||||
debug_assert_eq!(args.len(), 2);
|
|
||||||
|
|
||||||
let var = *args.get(1).unwrap();
|
|
||||||
|
|
||||||
list_layout_from_elem(env, var)
|
|
||||||
}
|
|
||||||
Content::FlexVar(_) | Content::RigidVar(_) => {
|
Content::FlexVar(_) | Content::RigidVar(_) => {
|
||||||
// If this was still a (List *) then it must have been an empty list
|
// If this was still a (List *) then it must have been an empty list
|
||||||
Ok(Layout::Builtin(Builtin::EmptyList))
|
Ok(Layout::Builtin(Builtin::EmptyList))
|
||||||
|
|
|
@ -823,7 +823,6 @@ fn count_arguments(tipe: &ErrorType) -> usize {
|
||||||
|
|
||||||
match tipe {
|
match tipe {
|
||||||
Function(args, _, _) => args.len(),
|
Function(args, _, _) => args.len(),
|
||||||
Type(Symbol::ATTR_ATTR, args) => count_arguments(&args[1]),
|
|
||||||
Alias(_, _, actual) => count_arguments(actual),
|
Alias(_, _, actual) => count_arguments(actual),
|
||||||
_ => 0,
|
_ => 0,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use roc_can::constraint::Constraint::{self, *};
|
use roc_can::constraint::Constraint::{self, *};
|
||||||
use roc_can::expected::{Expected, PExpected};
|
use roc_can::expected::{Expected, PExpected};
|
||||||
use roc_collections::all::{ImMap, MutMap};
|
use roc_collections::all::{ImMap, MutMap};
|
||||||
use roc_module::ident::TagName;
|
|
||||||
use roc_module::symbol::Symbol;
|
use roc_module::symbol::Symbol;
|
||||||
use roc_region::all::{Located, Region};
|
use roc_region::all::{Located, Region};
|
||||||
use roc_types::solved_types::Solved;
|
use roc_types::solved_types::Solved;
|
||||||
|
@ -872,98 +871,39 @@ fn check_for_infinite_type(
|
||||||
) {
|
) {
|
||||||
let var = loc_var.value;
|
let var = loc_var.value;
|
||||||
|
|
||||||
let is_uniq_infer = matches!(
|
while let Some((recursive, _chain)) = subs.occurs(var) {
|
||||||
subs.get_ref(var).content,
|
|
||||||
Content::Alias(Symbol::ATTR_ATTR, _, _)
|
|
||||||
);
|
|
||||||
|
|
||||||
while let Some((recursive, chain)) = subs.occurs(var) {
|
|
||||||
let description = subs.get(recursive);
|
let description = subs.get(recursive);
|
||||||
let content = description.content;
|
let content = description.content;
|
||||||
|
|
||||||
// try to make a tag union recursive, see if that helps
|
// try to make a tag union recursive, see if that helps
|
||||||
match content {
|
match content {
|
||||||
Content::Structure(FlatType::TagUnion(tags, ext_var)) => {
|
Content::Structure(FlatType::TagUnion(tags, ext_var)) => {
|
||||||
if !is_uniq_infer {
|
let rec_var = subs.fresh_unnamed_flex_var();
|
||||||
let rec_var = subs.fresh_unnamed_flex_var();
|
subs.set_rank(rec_var, description.rank);
|
||||||
subs.set_rank(rec_var, description.rank);
|
subs.set_content(
|
||||||
subs.set_content(
|
rec_var,
|
||||||
rec_var,
|
Content::RecursionVar {
|
||||||
Content::RecursionVar {
|
opt_name: None,
|
||||||
opt_name: None,
|
structure: recursive,
|
||||||
structure: recursive,
|
},
|
||||||
},
|
);
|
||||||
);
|
|
||||||
|
|
||||||
let mut new_tags = MutMap::default();
|
let mut new_tags = MutMap::default();
|
||||||
|
|
||||||
for (label, args) in &tags {
|
for (label, args) in &tags {
|
||||||
let new_args: Vec<_> = args
|
let new_args: Vec<_> = args
|
||||||
.iter()
|
.iter()
|
||||||
.map(|var| subs.explicit_substitute(recursive, rec_var, *var))
|
.map(|var| subs.explicit_substitute(recursive, rec_var, *var))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
new_tags.insert(label.clone(), new_args);
|
new_tags.insert(label.clone(), new_args);
|
||||||
}
|
|
||||||
|
|
||||||
let new_ext_var = subs.explicit_substitute(recursive, rec_var, ext_var);
|
|
||||||
|
|
||||||
let flat_type = FlatType::RecursiveTagUnion(rec_var, new_tags, new_ext_var);
|
|
||||||
|
|
||||||
subs.set_content(recursive, Content::Structure(flat_type));
|
|
||||||
} else {
|
|
||||||
// Sometimes, the recursion "starts" at the tag-union, not an `Attr`. Here we
|
|
||||||
// We use the path that `occurs` took to find the recursion to go one step
|
|
||||||
// forward in the recursion and find the `Attr` there.
|
|
||||||
let index = 0;
|
|
||||||
match subs.get(chain[index]).content {
|
|
||||||
Content::Structure(FlatType::Apply(Symbol::ATTR_ATTR, args)) => {
|
|
||||||
debug_assert!(args.len() == 2);
|
|
||||||
debug_assert!(
|
|
||||||
subs.get_root_key_without_compacting(recursive)
|
|
||||||
== subs.get_root_key_without_compacting(args[1])
|
|
||||||
);
|
|
||||||
|
|
||||||
// NOTE this ensures we use the same uniqueness var for the whole spine
|
|
||||||
// that might add too much uniqueness restriction.
|
|
||||||
// using `subs.fresh_unnamed_flex_var()` loosens it.
|
|
||||||
let uniq_var = args[0];
|
|
||||||
let tag_union_var = recursive;
|
|
||||||
let recursive = chain[index];
|
|
||||||
|
|
||||||
correct_recursive_attr(
|
|
||||||
subs,
|
|
||||||
recursive,
|
|
||||||
uniq_var,
|
|
||||||
tag_union_var,
|
|
||||||
ext_var,
|
|
||||||
description.rank,
|
|
||||||
&tags,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
_ => circular_error(subs, problems, symbol, &loc_var),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Content::Structure(FlatType::Apply(Symbol::ATTR_ATTR, args)) => {
|
|
||||||
debug_assert!(args.len() == 2);
|
|
||||||
let uniq_var = args[0];
|
|
||||||
let tag_union_var = args[1];
|
|
||||||
let nested_description = subs.get(tag_union_var);
|
|
||||||
match nested_description.content {
|
|
||||||
Content::Structure(FlatType::TagUnion(tags, ext_var)) => {
|
|
||||||
correct_recursive_attr(
|
|
||||||
subs,
|
|
||||||
recursive,
|
|
||||||
uniq_var,
|
|
||||||
tag_union_var,
|
|
||||||
ext_var,
|
|
||||||
description.rank,
|
|
||||||
&tags,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
_ => circular_error(subs, problems, symbol, &loc_var),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let new_ext_var = subs.explicit_substitute(recursive, rec_var, ext_var);
|
||||||
|
|
||||||
|
let flat_type = FlatType::RecursiveTagUnion(rec_var, new_tags, new_ext_var);
|
||||||
|
|
||||||
|
subs.set_content(recursive, Content::Structure(flat_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
_other => circular_error(subs, problems, symbol, &loc_var),
|
_other => circular_error(subs, problems, symbol, &loc_var),
|
||||||
|
@ -971,54 +911,6 @@ fn check_for_infinite_type(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn content_attr(u: Variable, a: Variable) -> Content {
|
|
||||||
Content::Structure(FlatType::Apply(Symbol::ATTR_ATTR, vec![u, a]))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn correct_recursive_attr(
|
|
||||||
subs: &mut Subs,
|
|
||||||
recursive: Variable,
|
|
||||||
uniq_var: Variable,
|
|
||||||
tag_union_var: Variable,
|
|
||||||
ext_var: Variable,
|
|
||||||
recursion_var_rank: Rank,
|
|
||||||
tags: &MutMap<TagName, Vec<Variable>>,
|
|
||||||
) {
|
|
||||||
let rec_var = subs.fresh_unnamed_flex_var();
|
|
||||||
let attr_var = subs.fresh_unnamed_flex_var();
|
|
||||||
|
|
||||||
let content = content_attr(uniq_var, rec_var);
|
|
||||||
subs.set_content(attr_var, content);
|
|
||||||
|
|
||||||
subs.set_rank(rec_var, recursion_var_rank);
|
|
||||||
subs.set_content(
|
|
||||||
rec_var,
|
|
||||||
Content::RecursionVar {
|
|
||||||
opt_name: None,
|
|
||||||
structure: recursive,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut new_tags = MutMap::default();
|
|
||||||
|
|
||||||
let new_ext_var = subs.explicit_substitute(recursive, attr_var, ext_var);
|
|
||||||
for (label, args) in tags {
|
|
||||||
let new_args: Vec<_> = args
|
|
||||||
.iter()
|
|
||||||
.map(|var| subs.explicit_substitute(recursive, attr_var, *var))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
new_tags.insert(label.clone(), new_args);
|
|
||||||
}
|
|
||||||
|
|
||||||
let new_tag_type = FlatType::RecursiveTagUnion(rec_var, new_tags, new_ext_var);
|
|
||||||
subs.set_content(tag_union_var, Content::Structure(new_tag_type));
|
|
||||||
|
|
||||||
let new_recursive = content_attr(uniq_var, tag_union_var);
|
|
||||||
|
|
||||||
subs.set_content(recursive, new_recursive);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn circular_error(
|
fn circular_error(
|
||||||
subs: &mut Subs,
|
subs: &mut Subs,
|
||||||
problems: &mut Vec<TypeError>,
|
problems: &mut Vec<TypeError>,
|
||||||
|
|
|
@ -140,11 +140,6 @@ fn find_names_needed(
|
||||||
// We must not accidentally generate names that collide with them!
|
// We must not accidentally generate names that collide with them!
|
||||||
names_taken.insert(name);
|
names_taken.insert(name);
|
||||||
}
|
}
|
||||||
Structure(Apply(Symbol::ATTR_ATTR, args)) => {
|
|
||||||
// assign uniqueness var names based on when they occur in the base type
|
|
||||||
find_names_needed(args[1], subs, roots, root_appearances, names_taken);
|
|
||||||
find_names_needed(args[0], subs, roots, root_appearances, names_taken);
|
|
||||||
}
|
|
||||||
Structure(Apply(_, args)) => {
|
Structure(Apply(_, args)) => {
|
||||||
for var in args {
|
for var in args {
|
||||||
find_names_needed(var, subs, roots, root_appearances, names_taken);
|
find_names_needed(var, subs, roots, root_appearances, names_taken);
|
||||||
|
@ -195,17 +190,12 @@ fn find_names_needed(
|
||||||
find_names_needed(ext_var, subs, roots, root_appearances, names_taken);
|
find_names_needed(ext_var, subs, roots, root_appearances, names_taken);
|
||||||
find_names_needed(rec_var, subs, roots, root_appearances, names_taken);
|
find_names_needed(rec_var, subs, roots, root_appearances, names_taken);
|
||||||
}
|
}
|
||||||
Alias(symbol, args, _actual) => {
|
Alias(_symbol, args, _actual) => {
|
||||||
if let Symbol::ATTR_ATTR = symbol {
|
for (_, var) in args {
|
||||||
find_names_needed(args[0].1, subs, roots, root_appearances, names_taken);
|
find_names_needed(var, subs, roots, root_appearances, names_taken);
|
||||||
find_names_needed(args[1].1, subs, roots, root_appearances, names_taken);
|
|
||||||
} else {
|
|
||||||
for (_, var) in args {
|
|
||||||
find_names_needed(var, subs, roots, root_appearances, names_taken);
|
|
||||||
}
|
|
||||||
// TODO should we also look in the actual variable?
|
|
||||||
// find_names_needed(_actual, subs, roots, root_appearances, names_taken);
|
|
||||||
}
|
}
|
||||||
|
// TODO should we also look in the actual variable?
|
||||||
|
// find_names_needed(_actual, subs, roots, root_appearances, names_taken);
|
||||||
}
|
}
|
||||||
Error | Structure(Erroneous(_)) | Structure(EmptyRecord) | Structure(EmptyTagUnion) => {
|
Error | Structure(Erroneous(_)) | Structure(EmptyRecord) | Structure(EmptyTagUnion) => {
|
||||||
// Errors and empty records don't need names.
|
// Errors and empty records don't need names.
|
||||||
|
@ -325,24 +315,6 @@ fn write_content(env: &Env, content: Content, subs: &Subs, buf: &mut String, par
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
||||||
Structure(FlatType::Apply(Symbol::ATTR_ATTR, nested_args)) => {
|
|
||||||
let attr_content = subs.get_without_compacting(nested_args[1]).content;
|
|
||||||
match &attr_content {
|
|
||||||
Alias(nested, _, _) => match *nested {
|
|
||||||
Symbol::NUM_INTEGER => buf.push_str("I64"),
|
|
||||||
Symbol::NUM_FLOATINGPOINT => buf.push_str("F64"),
|
|
||||||
_ => write_parens!(write_parens, buf, {
|
|
||||||
buf.push_str("Num ");
|
|
||||||
write_content(env, content, subs, buf, parens);
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
_ => write_parens!(write_parens, buf, {
|
|
||||||
buf.push_str("Num ");
|
|
||||||
write_content(env, content, subs, buf, parens);
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_ => write_parens!(write_parens, buf, {
|
_ => write_parens!(write_parens, buf, {
|
||||||
buf.push_str("Num ");
|
buf.push_str("Num ");
|
||||||
write_content(env, content, subs, buf, parens);
|
write_content(env, content, subs, buf, parens);
|
||||||
|
@ -598,11 +570,6 @@ pub fn chase_ext_tag_union(
|
||||||
|
|
||||||
chase_ext_tag_union(subs, ext_var, fields)
|
chase_ext_tag_union(subs, ext_var, fields)
|
||||||
}
|
}
|
||||||
Content::Structure(Apply(Symbol::ATTR_ATTR, arguments)) => {
|
|
||||||
debug_assert_eq!(arguments.len(), 2);
|
|
||||||
|
|
||||||
chase_ext_tag_union(subs, arguments[1], fields)
|
|
||||||
}
|
|
||||||
Content::Alias(_, _, var) => chase_ext_tag_union(subs, var, fields),
|
Content::Alias(_, _, var) => chase_ext_tag_union(subs, var, fields),
|
||||||
|
|
||||||
content => Err((var, content)),
|
content => Err((var, content)),
|
||||||
|
@ -626,12 +593,6 @@ pub fn chase_ext_record(
|
||||||
|
|
||||||
Structure(EmptyRecord) => Ok(()),
|
Structure(EmptyRecord) => Ok(()),
|
||||||
|
|
||||||
Content::Structure(Apply(Symbol::ATTR_ATTR, arguments)) => {
|
|
||||||
debug_assert_eq!(arguments.len(), 2);
|
|
||||||
|
|
||||||
chase_ext_record(subs, arguments[1], fields)
|
|
||||||
}
|
|
||||||
|
|
||||||
Alias(_, _, var) => chase_ext_record(subs, var, fields),
|
Alias(_, _, var) => chase_ext_record(subs, var, fields),
|
||||||
|
|
||||||
content => Err((var, content)),
|
content => Err((var, content)),
|
||||||
|
@ -683,25 +644,6 @@ fn write_apply(
|
||||||
Symbol::NUM_FLOATINGPOINT if nested_args.len() == 1 => {
|
Symbol::NUM_FLOATINGPOINT if nested_args.len() == 1 => {
|
||||||
buf.push_str("F64");
|
buf.push_str("F64");
|
||||||
}
|
}
|
||||||
Symbol::ATTR_ATTR => match nested_args
|
|
||||||
.get(1)
|
|
||||||
.map(|v| subs.get_without_compacting(*v).content)
|
|
||||||
{
|
|
||||||
Some(Content::Structure(FlatType::Apply(
|
|
||||||
double_nested_symbol,
|
|
||||||
double_nested_args,
|
|
||||||
))) => match double_nested_symbol {
|
|
||||||
Symbol::NUM_INTEGER if double_nested_args.len() == 1 => {
|
|
||||||
buf.push_str("I64");
|
|
||||||
}
|
|
||||||
Symbol::NUM_FLOATINGPOINT if double_nested_args.len() == 1 => {
|
|
||||||
buf.push_str("F64");
|
|
||||||
}
|
|
||||||
_ => default_case(subs, arg_content),
|
|
||||||
},
|
|
||||||
|
|
||||||
_other => default_case(subs, arg_content),
|
|
||||||
},
|
|
||||||
_ => default_case(subs, arg_content),
|
_ => default_case(subs, arg_content),
|
||||||
},
|
},
|
||||||
_ => default_case(subs, arg_content),
|
_ => default_case(subs, arg_content),
|
||||||
|
|
|
@ -363,11 +363,7 @@ impl Type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn is_recursive(&self) -> bool {
|
pub fn is_recursive(&self) -> bool {
|
||||||
match self {
|
matches!(self, Type::RecursiveTagUnion(_, _, _))
|
||||||
Type::RecursiveTagUnion(_, _, _) => true,
|
|
||||||
Type::Alias(Symbol::ATTR_ATTR, _, actual) => actual.is_recursive(),
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn variables(&self) -> ImSet<Variable> {
|
pub fn variables(&self) -> ImSet<Variable> {
|
||||||
|
|
|
@ -704,7 +704,6 @@ fn unify_tag_union_not_recursive_recursive(
|
||||||
fn is_structure(var: Variable, subs: &mut Subs) -> bool {
|
fn is_structure(var: Variable, subs: &mut Subs) -> bool {
|
||||||
match subs.get(var).content {
|
match subs.get(var).content {
|
||||||
Content::Alias(_, _, actual) => is_structure(actual, subs),
|
Content::Alias(_, _, actual) => is_structure(actual, subs),
|
||||||
Content::Structure(FlatType::Apply(Symbol::ATTR_ATTR, args)) => is_structure(args[1], subs),
|
|
||||||
Content::Structure(_) => true,
|
Content::Structure(_) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue