Merge pull request #2079 from rtfeldman/joshuawarner32/type-apply-package-name-fmt

Fix formatting in the presence of a pkg name in TypeAnnotation::Apply
This commit is contained in:
Richard Feldman 2021-11-26 18:02:51 -05:00 committed by GitHub
commit e2e095eb69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -277,7 +277,7 @@ impl<'a> Formattable<'a> for TypeAnnotation<'a> {
buf.push(')')
}
}
Apply(_, name, arguments) => {
Apply(pkg, name, arguments) => {
// NOTE apply is never multiline
let write_parens = parens == Parens::InApply && !arguments.is_empty();
@ -285,6 +285,11 @@ impl<'a> Formattable<'a> for TypeAnnotation<'a> {
buf.push('(')
}
if !pkg.is_empty() {
buf.push_str(pkg);
buf.push('.');
}
buf.push_str(name);
for argument in *arguments {

View File

@ -2654,6 +2654,18 @@ mod test_fmt {
));
}
#[test]
fn function_application_package_type() {
expr_formats_same(indoc!(
r#"
main : Task.Task {} []
main = 42
main
"#
));
}
#[test]
fn record_type() {
expr_formats_same(indoc!(