From c67a1bb8d41966b7c551678048c7691abdbcad02 Mon Sep 17 00:00:00 2001 From: Sean Hagstrom Date: Fri, 15 Apr 2022 13:36:27 +0100 Subject: [PATCH] fix(repl) and fix(pretty_print): update pretty_print output for `Num FloatingPoint *` to be `Float *` instead of `F64` --- compiler/solve/tests/solve_expr.rs | 6 +++--- compiler/types/src/pretty_print.rs | 13 ++++++++++++- repl_test/src/tests.rs | 6 +++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/compiler/solve/tests/solve_expr.rs b/compiler/solve/tests/solve_expr.rs index cf822538a2..e08c2e049b 100644 --- a/compiler/solve/tests/solve_expr.rs +++ b/compiler/solve/tests/solve_expr.rs @@ -2397,7 +2397,7 @@ mod solve_expr { { numIdentity, x : numIdentity 42, y } "# ), - "{ numIdentity : Num a -> Num a, x : Num a, y : F64 }", + "{ numIdentity : Num a -> Num a, x : Num a, y : Float * }", ); } @@ -3820,7 +3820,7 @@ mod solve_expr { negatePoint { x: 1, y: 2.1, z: 0x3 } "# ), - "{ x : Num a, y : F64, z : Int * }", + "{ x : Num a, y : Float *, z : Int * }", ); } @@ -3837,7 +3837,7 @@ mod solve_expr { { a, b } "# ), - "{ a : { x : Num a, y : F64, z : c }, b : { blah : Str, x : Num a, y : F64, z : c } }", + "{ a : { x : Num a, y : Float *, z : c }, b : { blah : Str, x : Num a, y : Float *, z : c } }", ); } diff --git a/compiler/types/src/pretty_print.rs b/compiler/types/src/pretty_print.rs index e4e8456fe3..148186e444 100644 --- a/compiler/types/src/pretty_print.rs +++ b/compiler/types/src/pretty_print.rs @@ -387,7 +387,18 @@ fn write_content<'a>( false, ); } - Symbol::NUM_FLOATINGPOINT => buf.push_str("F64"), + Symbol::NUM_FLOATINGPOINT => { + let content = get_single_arg(subs, &args); + match content { + Alias(Symbol::NUM_BINARY32, _, _, _) => buf.push_str("F32"), + Alias(Symbol::NUM_BINARY64, _, _, _) => buf.push_str("F64"), + Alias(Symbol::NUM_DECIMAL, _, _, _) => buf.push_str("Dec"), + _ => write_parens!(write_parens, buf, { + buf.push_str("Float "); + write_content(env, ctx, content, subs, buf, parens); + }), + } + } _ => write_parens!(write_parens, buf, { buf.push_str("Num "); diff --git a/repl_test/src/tests.rs b/repl_test/src/tests.rs index 9f46137f38..d0360ac569 100644 --- a/repl_test/src/tests.rs +++ b/repl_test/src/tests.rs @@ -50,7 +50,7 @@ fn int_addition() { #[test] fn float_addition() { - expect_success("1.1 + 2", "3.1 : F64"); + expect_success("1.1 + 2", "3.1 : Float *"); } #[cfg(not(feature = "wasm"))] @@ -309,7 +309,7 @@ fn nested_int_list() { fn nested_float_list() { expect_success( r#"[ [ [ 4, 3, 2 ], [ 1, 0.0 ] ], [ [] ], [] ]"#, - r#"[ [ [ 4, 3, 2 ], [ 1, 0 ] ], [ [] ], [] ] : List (List (List F64))"#, + r#"[ [ [ 4, 3, 2 ], [ 1, 0 ] ], [ [] ], [] ] : List (List (List (Float *)))"#, ); } @@ -403,7 +403,7 @@ fn list_contains() { fn list_sum() { expect_success("List.sum []", "0 : Num *"); expect_success("List.sum [ 1, 2, 3 ]", "6 : Num *"); - expect_success("List.sum [ 1.1, 2.2, 3.3 ]", "6.6 : F64"); + expect_success("List.sum [ 1.1, 2.2, 3.3 ]", "6.6 : Float *"); } #[cfg(not(feature = "wasm"))]