racket / macro-debugger

Other
8 stars 16 forks source link

Internal error due to compile-time exception in a macro #36

Closed sorawee closed 3 years ago

sorawee commented 3 years ago

Consider:

#lang racket

(require (for-syntax syntax/apply-transformer))

(begin-for-syntax
  (define (test stx)
    (raise 1)))

(define-syntax (foo stx)
  (with-handlers ([number? (λ (exn) #'1)])
    (local-apply-transformer test #'1 'expression)))

(foo)

(foo) expands to 1 as expected, but the macro stepper fails with the error:

Internal error:
add-step: contract violation
  expected: protostep?
  given: (list (remarkstep 'remark (state #f '() '(#<procedure:...r/model/context.rkt:129:0>) '(#<bigframe> #<bigframe>) '#hasheq((#<syntax with-handlers-handler2> . 1) (#<syntax:Users/sorawee/projects/mixfix/test.rkt:6:16 stx> . 1) (#<syntax with-handlers-predi...
  in: the 1st argument of
      (->* (protostep?) (any/c) void?)
  contract from: 
      <pkgs>/macro-debugger-text-lib/macro-debugger/model/reductions-util.rkt
  blaming: <pkgs>/macro-debugger-text-lib/macro-debugger/model/reductions.rkt
   (assuming the contract is correct)
  at: <pkgs>/macro-debugger-text-lib/macro-debugger/model/reductions-util.rkt:95.3