diff --git a/tests/wake-format/basic/basic.wake b/tests/wake-format/basic/basic.wake index f86d1c193..9e195fe89 100644 --- a/tests/wake-format/basic/basic.wake +++ b/tests/wake-format/basic/basic.wake @@ -620,12 +620,16 @@ global export data Let = def x + y = add x y +export def (argument: a) | (pipeFn: a => b): b = + pipeFn argument + def tool (dir: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) = "" def tool (dir: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) = "" def Pair _ _: Pair Integer String = Pair 44 "as" +def Pair _ _ : Pair Integer String = Pair 44 "as" def f0 = match _ _ (x: Integer) (True: Boolean) = x+1 diff --git a/tests/wake-format/basic/stdout b/tests/wake-format/basic/stdout index 9180ddb1b..ca31d9f35 100644 --- a/tests/wake-format/basic/stdout +++ b/tests/wake-format/basic/stdout @@ -764,10 +764,15 @@ global export data Let = def x + y = add x y +export def (argument: a) | (pipeFn: a => b): b = pipeFn argument + def tool (dir: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) = "" def tool (dir: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) (addHeaders: String) = "" +def Pair _ _: Pair Integer String = + Pair 44 "as" + def Pair _ _: Pair Integer String = Pair 44 "as" diff --git a/tools/wake-format/emitter.cpp b/tools/wake-format/emitter.cpp index 975c68580..a11301de3 100644 --- a/tools/wake-format/emitter.cpp +++ b/tools/wake-format/emitter.cpp @@ -114,18 +114,6 @@ static inline bool is_simple_literal(wcl::doc_builder& builder, ctx_t ctx, CSTEl return part.empty(); } -static inline bool contains_req_else(wcl::doc_builder& builder, ctx_t ctx, CSTElement& node, - const token_traits_map_t& traits) { - CSTElement copy = node; - while (!copy.empty()) { - if (copy.id() == CST_REQ_ELSE) { - return true; - } - copy.nextSiblingElement(); - } - return false; -} - static bool compare_doc_height(const wcl::doc& lhs, const wcl::doc& rhs) { return lhs->height() < rhs->height(); } @@ -255,10 +243,8 @@ static size_t count_allowed_newlines(const token_traits_map_t& traits, static wcl::doc select_best_choice(std::vector> choices) { std::vector lte_fmt = {}; std::vector gt_fmt = {}; - int i = 0; for (auto choice_opt : choices) { - i++; if (!choice_opt) { continue; } @@ -1130,6 +1116,7 @@ wcl::doc Emitter::walk_ascribe(ctx_t ctx, CSTElement node) { MEMO(ctx, node); MEMO_RET(fmt() .walk(WALK_NODE) + .consume_wsnlc() .token(TOKEN_P_ASCRIBE) .ws() .walk(WALK_NODE) @@ -1263,6 +1250,14 @@ wcl::doc Emitter::walk_binary(ctx_t ctx, CSTElement node) { parts = collect_right_binary(op_token, node); } + if (ctx.explode_option == ExplodeOption::Prevent) { + auto doc = combine_flat(op_token, ctx.binop(), parts); + if (!doc) { + FMT_ASSERT(false, op_token, "Failed to flat format binop"); + } + MEMO_RET(*doc); + } + if (!ctx.nested_binop && (is_binop_matching_str(op_token, TOKEN_OP_DOLLAR, "$") || is_binop_matching_str(op_token, TOKEN_OP_OR, "|"))) { MEMO_RET(select_best_choice({