Render record types with spaces
@@ -78,6 +78,9 @@ impl Type {
Type::Tuple { elems, .. } => args_to_gleam_doc(elems, names, uid).surround("{", "}"),
Type::Record { row } => {
+ if let Type::RowNil { .. } = **row {
+ return "{}".to_doc();
+ }
let mut row_to_doc = |row: &Type| {
let mut fields = ordmap![];
let tail = row.gather_fields(&mut fields);
@@ -103,7 +106,6 @@ impl Type {
.append(fields_doc),
}
};
-
"{".to_doc()
.append(
break_("", " ")
@@ -2515,12 +2517,6 @@ fn infer_test() {
src: "fn(f, x) { f(f(x)) }",
typ: "fn(fn(a) -> a, a) -> a",
},
- // TODO: This is allowed in the Erlang implementation due to how the pattern
- // assignments work. Unclear what the implications of this would be.
- Case {
- src: "fn(x) { let y = fn(z) { z } y(y) }",
- typ: "fn(a) -> fn(b) -> b",
- },
Case {
src: "fn(x, y) { {x, y} }",
typ: "fn(a, b) -> {a, b}",
@@ -2969,18 +2965,17 @@ fn infer_module_test() {
fn open(I) -> Int
}",
},
- // Case {
- // src: "
- // pub fn status() { 1 }
- // pub fn list_of(x) { [x] }
- // pub fn get_age(person) { person.age }
- // test whatever { 1 }",
- // typ: "module {
- // fn get_age({a | age = b}) -> b
- // fn list_of(c) -> List(c)
- // fn status() -> Int
- // }",
- // },
+ Case {
+ src: "pub fn status() { 1 }
+ pub fn list_of(x) { [x] }
+ pub fn get_age(person) { person.age }
+ test whatever { 1 }",
+ typ: "module {
+ fn get_age({ b | age = a }) -> a
+ fn list_of(c) -> List(c)
+ fn status() -> Int
+}",
+ },
Case {
src: "pub external fn go(String) -> String = \"\" \"\"",
typ: "module { fn go(String) -> String }",
