mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
consider _ = someDef
definitions, where there is no symbol
This commit is contained in:
parent
002327e275
commit
bf4462c79a
1 changed files with 16 additions and 7 deletions
|
@ -749,8 +749,8 @@ impl DefOrdering {
|
||||||
references: &[(References, Region)],
|
references: &[(References, Region)],
|
||||||
capacity: usize,
|
capacity: usize,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// because of `Pair a b = someDef` patterns, we can have more symbols than defs
|
// NOTE: because of `Pair a b = someDef` patterns, we can have more symbols than defs
|
||||||
debug_assert!(symbol_to_id.len() >= capacity);
|
// but because `_ = someDef` we can also have more defs than symbols
|
||||||
|
|
||||||
let mut this = Self {
|
let mut this = Self {
|
||||||
home: env.home,
|
home: env.home,
|
||||||
|
@ -1103,7 +1103,6 @@ fn group_to_declaration(
|
||||||
for cycle in sccs {
|
for cycle in sccs {
|
||||||
if cycle.len() == 1 {
|
if cycle.len() == 1 {
|
||||||
let def_id = cycle[0];
|
let def_id = cycle[0];
|
||||||
let symbol = def_ids.get_symbol(def_id).unwrap();
|
|
||||||
|
|
||||||
match defs[def_id as usize].take() {
|
match defs[def_id as usize].take() {
|
||||||
Some(mut new_def) => {
|
Some(mut new_def) => {
|
||||||
|
@ -1132,23 +1131,28 @@ fn group_to_declaration(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => roc_error_macros::internal_error!("def not available {:?}", symbol),
|
None => {
|
||||||
|
// NOTE: a `_ = someDef` can mean we don't have a symbol here
|
||||||
|
let symbol = def_ids.get_symbol(def_id);
|
||||||
|
|
||||||
|
roc_error_macros::internal_error!("def not available {:?}", symbol)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let mut can_defs = Vec::new();
|
let mut can_defs = Vec::new();
|
||||||
|
|
||||||
// Topological sort gives us the reverse of the sorting we want!
|
// Topological sort gives us the reverse of the sorting we want!
|
||||||
for def_id in cycle.into_iter().rev() {
|
for def_id in cycle.into_iter().rev() {
|
||||||
let symbol = def_ids.get_symbol(def_id).unwrap();
|
|
||||||
match defs[def_id as usize].take() {
|
match defs[def_id as usize].take() {
|
||||||
Some(mut new_def) => {
|
Some(mut new_def) => {
|
||||||
// Determine recursivity of closures that are not tail-recursive
|
// Determine recursivity of closures that are not tail-recursive
|
||||||
if let Closure(ClosureData {
|
if let Closure(ClosureData {
|
||||||
recursive: recursive @ Recursive::NotRecursive,
|
recursive: recursive @ Recursive::NotRecursive,
|
||||||
|
name,
|
||||||
..
|
..
|
||||||
}) = &mut new_def.loc_expr.value
|
}) = &mut new_def.loc_expr.value
|
||||||
{
|
{
|
||||||
*recursive = closure_recursivity(symbol, closures);
|
*recursive = closure_recursivity(*name, closures);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !seen_pattern_regions.contains(&new_def.loc_pattern.region) {
|
if !seen_pattern_regions.contains(&new_def.loc_pattern.region) {
|
||||||
|
@ -1157,7 +1161,12 @@ fn group_to_declaration(
|
||||||
can_defs.push(new_def);
|
can_defs.push(new_def);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => roc_error_macros::internal_error!("def not available {:?}", symbol),
|
None => {
|
||||||
|
// NOTE: a `_ = someDef` can mean we don't have a symbol here
|
||||||
|
let symbol = def_ids.get_symbol(def_id);
|
||||||
|
|
||||||
|
roc_error_macros::internal_error!("def not available {:?}", symbol)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue