From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxim Cournoyer Newsgroups: gmane.lisp.guile.bugs Subject: bug#66776: SRFI-64 test-error doesn't match error types Date: Mon, 11 Dec 2023 23:45:20 -0500 Message-ID: <878r60c9lr.fsf@gmail.com> References: <878r7nvrhc.fsf@gmail.com> <39291d90-04d8-4b2f-89db-b059ebc5733f@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16977"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 66776@debbugs.gnu.org To: Taylan Kammer Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Tue Dec 12 05:46:13 2023 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rCueq-0004Bm-K1 for guile-bugs@m.gmane-mx.org; Tue, 12 Dec 2023 05:46:12 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rCueT-0006Ip-R9; Mon, 11 Dec 2023 23:45:49 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rCueS-0006IZ-1J for bug-guile@gnu.org; Mon, 11 Dec 2023 23:45:48 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rCueR-0002K5-Ff for bug-guile@gnu.org; Mon, 11 Dec 2023 23:45:47 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rCueg-0001Il-6L for bug-guile@gnu.org; Mon, 11 Dec 2023 23:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 12 Dec 2023 04:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66776 X-GNU-PR-Package: guile Original-Received: via spool by 66776-submit@debbugs.gnu.org id=B66776.17023563484983 (code B ref 66776); Tue, 12 Dec 2023 04:46:02 +0000 Original-Received: (at 66776) by debbugs.gnu.org; 12 Dec 2023 04:45:48 +0000 Original-Received: from localhost ([127.0.0.1]:55105 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCueS-0001II-29 for submit@debbugs.gnu.org; Mon, 11 Dec 2023 23:45:48 -0500 Original-Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]:57849) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCueN-0001I3-7j for 66776@debbugs.gnu.org; Mon, 11 Dec 2023 23:45:46 -0500 Original-Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-4259cd18f85so30798151cf.3 for <66776@debbugs.gnu.org>; Mon, 11 Dec 2023 20:45:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702356322; x=1702961122; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=x2vlHzuvJ+eia9TFRvzh7yf6R6c/wg1xd0JlJx5lPYs=; b=RoOn+Ftc6YJBi+bb9vW582zo3/ILNhkUOLNlkw9NVQzLxl0IW4SRLJ9nRrBPY1Yr2I AXZtiRjHg56j+7873OBRmbJKS01BK15vVjWfAK4ya1X6X5LUaX9gxfLaiyeaDiC9SKD7 LW4oPA7J8BtilWk3nGHCpjudDGvG3ohoiDOStMY6qYktLiIqAn2Qf2SHzfS3vwz4sFTc ZzNWXBIAErbagLJ7zGYrFtKlYn4CfHHEgn76/quyf74k6oJ6yYgn/LXC47irtnBHvH5l iBrXPre4YWPuAF68moktq2BUJQEKrMSnC/gCNOcxDJM/QMXsmJ8EABFtUKnSwhP/KGxp qIGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702356322; x=1702961122; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=x2vlHzuvJ+eia9TFRvzh7yf6R6c/wg1xd0JlJx5lPYs=; b=grjjcT3Q7p4eTXYJeGaWKxuQP1pj2JMyv2gQOdg2h4nKphibMpybv5I5nWCZpOdrbO M7NYyGjpdL6DLcEWeg4WQ6tlbIBkEsrmNZUGRimNUApBns4wj1uw2fg1fVrpXNtMJCt6 Dr/o8EQpZYEwuPyYfZvCYVhKMVzcjoXLqdvZhZNh5lu0wpXSbTGdKKAHWvYjoevFlrjQ wJe46Qtvp9lLnF7ZBuOOFOfVmGEsdnF3Bm8/logEIvGOS0K7HQUltpJEx1HZEJ6nFp7E 0IwNKIsnF25tx8r7hSnsOPTTd5XsuJkHCI7kvTRLwyRy/q/v7FwoICyzbHng+VweCMg6 xncA== X-Gm-Message-State: AOJu0Yw2eEEsJsXeLwGstcdl/cnuqw5smX5E+1TKpFAbUdoVu3i44U+u rg4b5536dAydPsJzhWbbQmEwycT8ZQw= X-Google-Smtp-Source: AGHT+IG2iFbRw9Rc1ysXssK4IowSK+41F1vgr6zdiasSY0NjK9DkSVq7DRfCB5/Q9IuwsDshUL/J6w== X-Received: by 2002:a05:622a:2d6:b0:417:9c63:391c with SMTP id a22-20020a05622a02d600b004179c63391cmr7183034qtx.52.1702356321778; Mon, 11 Dec 2023 20:45:21 -0800 (PST) Original-Received: from hurd (dsl-157-186.b2b2c.ca. [66.158.157.186]) by smtp.gmail.com with ESMTPSA id z26-20020ac8455a000000b0042387bd254bsm3781333qtn.9.2023.12.11.20.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 20:45:21 -0800 (PST) In-Reply-To: <39291d90-04d8-4b2f-89db-b059ebc5733f@gmail.com> (Taylan Kammer's message of "Sat, 28 Oct 2023 20:10:32 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.bugs:10729 Archived-At: Hi Taylan, Taylan Kammer writes: > On 27.10.2023 20:40, Maxim Cournoyer wrote: >> >> There is a more modern implementation of SRFI-64 out there for Guile >> which may provide clues or be used wholesale, though I haven't tried it: >> . >> > > FYI, this is how I check whether a caught error matches the 'type': > > (define (error-matches? error type) > (cond > ((eq? type #t) > #t) > ((condition-type? type) > (and (condition? error) (condition-has-type? error type))) > ((procedure? type) > (type error)) > (else > (let ((runner (test-runner-get))) > ((%test-runner-on-bad-error-type runner) runner type error)) > #f))) > > Defined on Line 336 in execution.body.scm: > > https://codeberg.org/taylan/scheme-srfis/src/branch/master/srfi/64/execution.body.scm#L336 > > In summary, other than #t to match anything, 'type' can be: > > - A SRFI 35 condition-type object > > - A procedure, which will be called as a predicate on the error > > The predicate case should cover the Guile and R6RS exception systems, > which both simply use predicates to detect condition/exception type > from what I can tell: > > https://www.gnu.org/software/guile/manual/html_node/Exception-Objects.html > > https://www.gnu.org/software/guile/manual/html_node/rnrs-conditions.html I've tried your SRFI 64 R7RS implementation, and it passes my earlier tests: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> (use-modules (srfi srfi-64)) scheme@(guile-user)> (test-begin "test") (test-error "testing" 'bad (throw 'oops)) (test-end "test") Writing log file: test.srfi64.log Test suite begin: test $1 = ("test") WARNING: unknown error type predicate: bad error was: #<&compound-exception components: (#<&error> #<&irritants irritants: ()> #<&exception-with-kind-and-args kind: oops args: ()>)> [FAIL] test: testing #f:2: (throw (quote oops)) Expected error: bad Raised error: #<&compound-exception components: (#<&error> #<&irritants irritants: ()> #<&exception-with-kind-and-args kind: oops args: ()>)> Test suite end: test Passes: 0 Expected failures: 0 Failures: 1 Unexpected passes: 0 Skipped tests: 0 Wrote log file: test.srfi64.log scheme@(guile-user)> (use-modules (ice-9 exceptions) (srfi srfi-64)) (define-exception-type &my-exception &exception ;parent make-my-exception ;constructor my-exception?) ;predicate (test-begin "test-error exception types") ;; Passes, but should fail. (test-error "&my-exception raised" &my-exception (raise-exception (make-error))) ;; OR ;; Unimplemented, but passes also. (test-error "&my-exception raised" my-exception? (raise-exception (make-error))) (test-begin "test-error exception types") Writing log file: test.srfi64.log Test suite begin: test-error exception types $2 = ("test-error exception types") [FAIL] test-error exception types: &my-exception raised #f:14: (raise-exception (make-error)) Expected error: # Raised error: #<&error> [FAIL] test-error exception types: &my-exception raised #f:21: (raise-exception (make-error)) Expected error: # Raised error: #<&error> $3 = ("test-error exception types" "test-error exception types") --8<---------------cut here---------------end--------------->8--- I'll send the patch upgrading our SRFI 64 implementation to it soon. -- Thanks, Maxim