mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
de-alias when diffing with a non-alias
When one of the types in a comparison is an alias, elm does not de-alias it. That is really annoying if e.g. the alias is of a record and you used an invalid field: the field suggestion error does not kick in
This commit is contained in:
parent
2811f978a4
commit
d15bd07bf4
5 changed files with 33 additions and 12 deletions
|
@ -462,7 +462,7 @@ impl<'a> RocDocAllocator<'a> {
|
|||
self.intersperse(docs, self.line())
|
||||
}
|
||||
|
||||
/// live vcat, but adds a double line break between elements. Visually this means an empty line
|
||||
/// like vcat, but adds a double line break between elements. Visually this means an empty line
|
||||
/// between elements.
|
||||
pub fn stack<A, I>(&'a self, docs: I) -> DocBuilder<'a, Self, A>
|
||||
where
|
||||
|
|
|
@ -170,7 +170,7 @@ fn to_expr_report<'b>(
|
|||
alloc.keyword("if"),
|
||||
alloc.text(" expression:"),
|
||||
]),
|
||||
TypedWhenBranch(index) => alloc.concat(vec![
|
||||
TypedWhenBranch { index } => alloc.concat(vec![
|
||||
alloc.string(index.ordinal()),
|
||||
alloc.reflow(" branch of this "),
|
||||
alloc.keyword("when"),
|
||||
|
@ -185,7 +185,7 @@ fn to_expr_report<'b>(
|
|||
|
||||
let it_is = match annotation_source {
|
||||
TypedIfBranch { index, .. } => format!("The {} branch is", index.ordinal()),
|
||||
TypedWhenBranch(index) => format!("The {} branch is", index.ordinal()),
|
||||
TypedWhenBranch { index, .. } => format!("The {} branch is", index.ordinal()),
|
||||
TypedBody => "The body is".into(),
|
||||
};
|
||||
|
||||
|
@ -1319,6 +1319,15 @@ fn to_diff<'b>(
|
|||
}
|
||||
}
|
||||
|
||||
(Alias(symbol, _, actual), other) if !symbol.module_id().is_builtin() => {
|
||||
// when diffing an alias with a non-alias, de-alias
|
||||
to_diff(alloc, parens, *actual, other)
|
||||
}
|
||||
(other, Alias(symbol, _, actual)) if !symbol.module_id().is_builtin() => {
|
||||
// when diffing an alias with a non-alias, de-alias
|
||||
to_diff(alloc, parens, other, *actual)
|
||||
}
|
||||
|
||||
(Record(fields1, ext1), Record(fields2, ext2)) => {
|
||||
diff_record(alloc, fields1, ext1, fields2, ext2)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue