mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
give better debug info for unresolved type variables
This commit is contained in:
parent
4b5a26ebc6
commit
a431af660d
3 changed files with 34 additions and 7 deletions
|
@ -4615,7 +4615,15 @@ fn reuse_function_symbol<'a>(
|
||||||
original: Symbol,
|
original: Symbol,
|
||||||
) -> Stmt<'a> {
|
) -> Stmt<'a> {
|
||||||
match procs.partial_procs.get(&original) {
|
match procs.partial_procs.get(&original) {
|
||||||
None => result,
|
None => {
|
||||||
|
// danger: a foreign symbol may not be specialized!
|
||||||
|
debug_assert!(
|
||||||
|
env.home == original.module_id() || original.module_id() == ModuleId::ATTR
|
||||||
|
);
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
Some(partial_proc) => {
|
Some(partial_proc) => {
|
||||||
let arg_var = arg_var.unwrap_or(partial_proc.annotation);
|
let arg_var = arg_var.unwrap_or(partial_proc.annotation);
|
||||||
// this symbol is a function, that is used by-name (e.g. as an argument to another
|
// this symbol is a function, that is used by-name (e.g. as an argument to another
|
||||||
|
|
|
@ -315,7 +315,10 @@ impl<'a> Layout<'a> {
|
||||||
|
|
||||||
match content {
|
match content {
|
||||||
FlexVar(_) | RigidVar(_) => Err(LayoutProblem::UnresolvedTypeVar(var)),
|
FlexVar(_) | RigidVar(_) => Err(LayoutProblem::UnresolvedTypeVar(var)),
|
||||||
RecursionVar { .. } => todo!("recursion var"),
|
RecursionVar { structure, .. } => {
|
||||||
|
let structure_content = env.subs.get_without_compacting(structure).content;
|
||||||
|
Self::new_help(env, structure, structure_content)
|
||||||
|
}
|
||||||
Structure(flat_type) => layout_from_flat_type(env, flat_type),
|
Structure(flat_type) => layout_from_flat_type(env, flat_type),
|
||||||
|
|
||||||
Alias(Symbol::NUM_INT, args, _) => {
|
Alias(Symbol::NUM_INT, args, _) => {
|
||||||
|
@ -751,7 +754,7 @@ fn layout_from_flat_type<'a>(
|
||||||
// Determine the layouts of the fields, maintaining sort order
|
// Determine the layouts of the fields, maintaining sort order
|
||||||
let mut layouts = Vec::with_capacity_in(sorted_fields.len(), arena);
|
let mut layouts = Vec::with_capacity_in(sorted_fields.len(), arena);
|
||||||
|
|
||||||
for (_, field) in sorted_fields {
|
for (label, field) in sorted_fields {
|
||||||
use LayoutProblem::*;
|
use LayoutProblem::*;
|
||||||
|
|
||||||
let field_var = {
|
let field_var = {
|
||||||
|
@ -776,7 +779,14 @@ fn layout_from_flat_type<'a>(
|
||||||
layouts.push(layout);
|
layouts.push(layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(UnresolvedTypeVar(_)) | Err(Erroneous) => {
|
Err(UnresolvedTypeVar(v)) => {
|
||||||
|
// Invalid field!
|
||||||
|
panic!(
|
||||||
|
r"I hit an unresolved type var {:?} when determining the layout of {:?} of record field: {:?} : {:?}",
|
||||||
|
field_var, v, label, field
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Err(Erroneous) => {
|
||||||
// Invalid field!
|
// Invalid field!
|
||||||
panic!("TODO gracefully handle record with invalid field.var");
|
panic!("TODO gracefully handle record with invalid field.var");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,21 @@
|
||||||
app Main provides [ main ] imports [ Effect, RBTree ]
|
app Main provides [ main ] imports [ Effect, RBTree ]
|
||||||
|
|
||||||
foo : RBTree.Dict Int Int
|
toAndFro : Int
|
||||||
foo = Empty # RBTree.empty
|
toAndFro =
|
||||||
|
empty : RBTree.Dict Int Int
|
||||||
|
empty = RBTree.empty
|
||||||
|
|
||||||
|
empty
|
||||||
|
|> RBTree.toList
|
||||||
|
|> List.len
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
main : Effect.Effect {} as Fx
|
main : Effect.Effect {} as Fx
|
||||||
main =
|
main =
|
||||||
# if RBTree.isEmpty empty then
|
# if RBTree.isEmpty empty then
|
||||||
if RBTree.size foo == 0 then
|
if toAndFro == 2 then
|
||||||
Effect.putLine "Yay"
|
Effect.putLine "Yay"
|
||||||
|> Effect.after (\{} -> Effect.getLine)
|
|> Effect.after (\{} -> Effect.getLine)
|
||||||
|> Effect.after (\line -> Effect.putLine line)
|
|> Effect.after (\line -> Effect.putLine line)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue