Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip check-satisfied in stepper #239

Merged
merged 2 commits into from
Dec 30, 2024
Merged

Conversation

shhyou
Copy link
Collaborator

@shhyou shhyou commented Dec 21, 2024

If I tested it correctly, the stepper from Racket v7 previously skips check-satisfied and the current bugs in it are unintentional. At some point, the stepper from Racket v8 no longer ignores check-satisfied and begins to step through all the with-handlers internal code or even breaks for non-identifier predicates.

This PR works around #232 and restores the previous behavior for check-satisfied by completely ignoring them. Proper support of check-satisfied is needed in the future.

@shhyou shhyou added stepper test engine topics related to the test engine labels Dec 21, 2024
@shhyou shhyou requested a review from jbclements December 21, 2024 02:52
@mikesperber mikesperber self-requested a review December 21, 2024 14:29
Copy link
Member

@mikesperber mikesperber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. (Even though I don't rememember changing this particular piece of code.)

@shhyou
Copy link
Collaborator Author

shhyou commented Dec 21, 2024

@mikesperber Yes, I think the code is never modified. I suppose these behavior changes are the unintended consequences of a combination of test engine changes and stepper changes elsewhere.

For this test case:

(check-expect 1 (+ 1 1))
(check-satisfied (* 2 2) even?)
(check-expect 3 (+ 1 2))

The stepper ignored (check-satisfied (* 2 2) even?) for Racket v8.2 and below. Starting from Racket v8.3 and above, it first shows (... {(* 2 2)} ...) -> (... {4} ...) and then begins to walk through this.

(let ((with-handlers-predicate1
        exn:fail:contract:arity?)
       (with-handlers-handler2
        (lambda (exn)
          (let ((msg (exn-message exn)))
            (let ((msg1
                   (regexp-match
                    (pregexp
                     "(.*): arity mismatch")
                    msg)))
              (cond
               (msg1
                (let ((raised-name (cadr msg1)))
                  (if (equal?
                       "even?"
                       raised-name)
                    (error-check
                     (lambda (v) #false)
                     "even?"
                     SATISFIED-FMT
                     #true)
                    (raise exn))))))))))
   (let ((bpz
          (continuation-mark-set-first
           #false
           break-enabled-key)))
     (call-handled-body
      bpz
      (lambda (e)
        (select-handler/no-breaks
         e
         bpz
         (list
          (cons
           with-handlers-predicate1
           with-handlers-handler2))))
      (lambda () (even? 4)))))

For the other two cases (e.g. (check-satisfied (+ 2 3) (lambda (n) (even? (sub1 n)))) (check-expect 3 (+ 1 2))), the stepper exhibits different errors:

  • Racket v7.9 and below: break-reconstruction: held-exp-list not empty when a double-break occurred
  • Racket v8.0 and above: the stepper first shows
    (do-check-satisfied
     (lambda () (+ 2 3))
     {(let ((p? (lambda (n) (even? (sub1 n)))))
       (let ((name (object-name p?)))
         (if (if (procedure? p?)
               (procedure-arity-includes? p? 1)
               #false)
           (void)
           (let ()
             (if name
               (error-check
                (lambda (v) #false)
                name
                SATISFIED-FMT
                #true)
               (error-check
                (lambda (v) #false)
                p?
                SATISFIED-FMT
                #true)))))
       p?)}
     "unknown name"
     (kernel:srcloc '3-unsaved-editor 1 0 1 55))
    ->
    {(define p?_0 (lambda (n) (even? (sub1 n))))}
    (do-check-satisfied
     (lambda () (+ 2 3))
     {(values
      (let ((name (object-name p?_0)))
        (if (if (procedure? p?_0)
              (procedure-arity-includes? p?_0 1)
              #false)
          (void)
          (let ()
            (if name
              (error-check
               (lambda (v) #false)
               name
               SATISFIED-FMT
               #true)
              (error-check
               (lambda (v) #false)
               p?_0
               SATISFIED-FMT
               #true)))))
      p?_0)}
     "unknown name"
     (kernel:srcloc '3-unsaved-editor 1 0 1 55))
    and then raises the error lookup-binding: variable not found in environment: lifter-p?-0.

@shhyou shhyou merged commit c529c9e into racket:master Dec 30, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stepper test engine topics related to the test engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants