racket / htdp

Other
91 stars 70 forks source link

Stepper produces error when stepping through world program #157

Open JustinHuPrime opened 5 years ago

JustinHuPrime commented 5 years ago

The teaching languages stepper produces an error when the next step would be to expand a big-bang form.

To Reproduce

Use the HtDP BSL language, and have a file that contains the big-bang form open. MWE below:

(require 2htdp/image)
(require 2htdp/universe)

(define MTS (empty-scene 500 500))

(define (square/blue n)
  (overlay (square n "solid" "blue")
           MTS))

(big-bang 0
  (on-tick add1)
  (to-draw square/blue))

Attempt to run the stepper on the big-bang. When the next step would be the big-bang, it instead produces an error:

skip-step?: contract violation
  expected: (or/c (listof procedure?) #f)
  given: (cons (lambda () ...) (cons "supposed to be skipped" (cons (lambda () ...) '())))
  in: the 2nd argument of
      (->
       (or/c
        'normal-break
        'normal-break/values
        'result-exp-break
        'result-value-break
        'double-break
        'late-let-break
        'expr-finished-break
        'define-struct-break)
       (or/c (listof procedure?) #f)
       render-settings?
       boolean?)
  contract from: 
      <pkgs>/htdp-lib/stepper/private/reconstruct.rkt
  blaming: <pkgs>/htdp-lib/stepper/private/model.rkt
   (assuming the contract is correct)
  at: <pkgs>/htdp-lib/stepper/private/reconstruct.rkt:48.2

Expected Behavior

The stepper should either completely ignore the big-bang form, and treat it as if it didn't exist in the file, or it should treat the big-bang form like a define form, and skip expanding it.

Environment Details

OS: Linux and Windows Racket Version: 7.2 and 7.0

I believe this is either a bug in the stepper itself, or a bug in the definition of big-bang in the teaching language. But since the bug seems to be in stepper/private, I think it is more likely to be a bug in the stepper itself.

rfindler commented 2 years ago

Also seems to reproduce in git head(ish; I may be some days behind actually)