# TR check-equal does not catch errors?

**URL:** <https://racket.discourse.group/t/tr-check-equal-does-not-catch-errors/2719>\
**Category:** General\
**Created:** [February 14, 2024, 11:23pm UTC](https://racket.discourse.group/t/tr-check-equal-does-not-catch-errors/2719 "2024-02-14T23:23:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbclements](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/jbclements/32/11_2.png) [@jbclements](https://racket.discourse.group/u/jbclements)\
**Post date:** [February 14, 2024, 11:23pm UTC](https://racket.discourse.group/t/tr-check-equal-does-not-catch-errors/2719/1 "2024-02-14T23:23:29Z")

</div>

It appears to me that racket and typed/racket behave differently with respect to errors that occur during the evaluation of arguments to check-equal?. Specifically, the program

```scheme
#lang typed/racket

(require typed/rackunit)

(check-equal? 3 (/ 1 0))

```

... halts with an error, whereas

```scheme
#lang racket

(require rackunit)

(check-equal? 3 (/ 1 0))

```

... signals a test case failure (and, presumably, continues to run tests).

Is this a deliberate design choice? It certainly looks like a bug.

EDIT: D'oh! yes, mis-pasted the second one.

---

<div class="post-metadata">

**Author:** ![samth](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/samth/32/3_2.png) [@samth](https://racket.discourse.group/u/samth)\
**Post date:** [February 15, 2024, 12:40am UTC](https://racket.discourse.group/t/tr-check-equal-does-not-catch-errors/2719/2 "2024-02-15T00:40:38Z")

</div>

Is there a typo somewhere? Those programs are identical.

---

<div class="post-metadata">

**Author:** ![shhyou](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@shhyou](https://racket.discourse.group/u/shhyou)\
**Post date:** [February 15, 2024, 1:09am UTC](https://racket.discourse.group/t/tr-check-equal-does-not-catch-errors/2719/3 "2024-02-15T01:09:17Z")

</div>

This errs:

```scheme
#lang typed/racket/baes
(require typed/rackunit)
(check-equal? 3 (/ 1 0))
(check-equal? 5 "not=")
;; . . /: division by zero

```

This also errs:

```scheme
#lang racket/base
(require typed/rackunit)
(check-equal? 3 (/ 1 0))
(check-equal? 5 "not=")
;; . . /: division by zero

```

This fails:

```scheme
#lang racket/base
(require rackunit)
(check-equal? 3 (/ 1 0))
(check-equal? 5 "not=")
;; --------------------
;; . ERROR
;; name: check-equal?
;; location: 3-unsaved-editor:3:0
;; 
;; /: division by zero
;; --------------------
;; --------------------
;; . FAILURE
;; name: check-equal?
;; location: 3-unsaved-editor:4:0
;; actual: 5
;; expected: "not="
;; --------------------

```

So it could be `typed/rackunit`?

---

<div class="post-metadata">

**Author:** ![shhyou](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@shhyou](https://racket.discourse.group/u/shhyou)\
**Post date:** [February 15, 2024, 1:25am UTC](https://racket.discourse.group/t/tr-check-equal-does-not-catch-errors/2719/4 "2024-02-15T01:25:33Z")

</div>

Well, it looks like `check-equal?` is a macro, so it's the untyped `check-equal?` that's special.

---

<div class="post-metadata">

**Author:** ![capfredf](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/capfredf/32/935_2.png) [@capfredf](https://racket.discourse.group/u/capfredf)\
**Post date:** [February 17, 2024, 4:30pm UTC](https://racket.discourse.group/t/tr-check-equal-does-not-catch-errors/2719/5 "2024-02-17T16:30:02Z")

</div>

I thought I filed an issue relating to this problem. 🙃

---

<div class="post-metadata">

**Author:** ![capfredf](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/capfredf/32/935_2.png) [@capfredf](https://racket.discourse.group/u/capfredf)\
**Post date:** [February 17, 2024, 4:34pm UTC](https://racket.discourse.group/t/tr-check-equal-does-not-catch-errors/2719/6 "2024-02-17T16:34:45Z")

</div>

`check-equal?` is indeed a macro, especially when it is called with arguments. It alone also expands to a function, which is kind of confusing. And the documentation might cause more confusion, as it says `check-*` are procedures.

---

<div class="post-metadata">

**Author:** ![yfzhe](https://avatars.discourse-cdn.com/v4/letter/y/f05b48/32.png) [@yfzhe](https://racket.discourse.group/u/yfzhe)\
**Post date:** [February 18, 2024, 6:20am UTC](https://racket.discourse.group/t/tr-check-equal-does-not-catch-errors/2719/7 "2024-02-18T06:20:29Z")

</div>

In the section 3.2 of RackUnit's doc, it says:

> Although checks are implemented as macros, which is necessary to grab source locations (see [Custom Checks](https://docs.racket-lang.org/rackunit/api.html#%28part._rackunit~3acustom-checks%29)), they are conceptually functions (with the exception of [check-match](https://docs.racket-lang.org/rackunit/api.html#%28form._%28%28lib._rackunit%2Fmain..rkt%29._check-match%29%29) below).
