From 28341632fd7e5df36c72adb1f98471def9a8c6fab53b2cebbac7b00a0e7e8244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Bj=C3=B6rnstam?= Date: Fri, 23 Oct 2026 11:55:17 +0200 Subject: [PATCH] smoke: a match with no clauses is offered a clause for each case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A match with no clauses yet, and one whose clauses all have a guard, was offered (_ _). The compiler now offers each case it lacks, and the smoke test checks that both are: ((Circle _) _), ((Square _) _), (Empty _) under the match, and None and (Some _) after the guarded clause. 🤖 Generated with [ECA](https://eca.dev) Co-Authored-By: eca-agent --- test/smoke.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/smoke.py b/test/smoke.py index c6345c2..5a88158 100755 --- a/test/smoke.py +++ b/test/smoke.py @@ -881,6 +881,20 @@ HOLES = """(type (: Shape (Union (: Circle int) (: Square int) Empty))) (defun (main) (println (int->string (total-size (list (default-shape))))) 0) """ +EMPTY_MATCH = """(type (: Shape (Union (: Circle int) (: Square int) Empty))) + +(: size (-> Shape int)) +(defun (size s) + (match s)) + +(: pick (-> (Option Shape) int)) +(defun (pick o) + (match o + (x #:when (some? x) 1))) + +(defun (main) (println (int->string (+ (size Empty) (pick None)))) 0) +""" + def applied(text, edits): """`text` with LSP text edits made, the last first.""" @@ -956,6 +970,22 @@ def acting(server, tmp): expect("actions: nothing is offered away from a hole", actions(uri, HOLES, "(defun (add-size", 8) == [], actions(uri, HOLES, "(defun (add-size", 8)) + + # A match with no clauses yet lacks every case, each its own clause, not + # one `_`; so does one whose clauses all have a guard. + uri, found = open_("empty-match.bjo", EMPTY_MATCH) + found = actions(uri, EMPTY_MATCH, "(match s", 1) + empty = edit_of(found, "Add the 3 missing clauses", uri) + expect("actions: a match with no clauses is offered every case", + empty is not None, [a["title"] for a in found]) + fixed = applied(EMPTY_MATCH, empty or []) + expect("actions: each case a clause, under the match", + " (match s\n ((Circle _) _)\n ((Square _) _)\n (Empty _)))" in fixed, fixed) + found = actions(uri, EMPTY_MATCH, "(match o", 1) + guarded = edit_of(found, "Add the 2 missing clauses", uri) + fixed = applied(EMPTY_MATCH, guarded or []) + expect("actions: clauses that all have a guard cover nothing, so every case is offered", + " (x #:when (some? x) 1)\n (None _)\n ((Some _) _)))" in fixed, fixed) server.diagnostics_after("textDocument/didClose", uri)