racket / htdp

Other
91 stars 69 forks source link

incorrect source line hyperlink from test-engine/racket-tests when two lines are mentioned #152

Closed maueroats closed 3 years ago

maueroats commented 3 years ago

What version of Racket are you using? 8.1 [cs]

What program did you run? [Note: much more minimal example added in comment.]

#lang racket
(require syntax/parse syntax/parse/define)
(require test-engine/racket-tests)

(module stx racket/base
  (require syntax/parse)
  (provide cond-QA)
  (define-syntax-class cond-QA
    (pattern [#:else answer]
             #:attr question #'#true)))

(require (for-syntax (submod "." stx)))

#;(begin-for-syntax
  (define-syntax-class cond-QA
    (pattern [#:else answer]
             #:attr question #'#true)))

(define-syntax-parse-rule (check-question e:cond-QA)
  e.question)

"notice that both lines are linked to the same place"

(check-expect (check-question [#:else 50])
              #true)
(test)

What happened?

The error message has both line 24 and line 10 hyperlinked to the source of the error on line 10.

What should have happened? Clicking on the underlined "line 24" part of the error message should have jumped to line 24, or possibly it should not be hyperlinked.

If you got an error message, please include it here. 2021-06-19-at-23-22

Please include any other relevant details Linux. Running in DrRacket. Note that the problem is not that the error occurs, just that the link is wrong. Sorry I don't think this is "minimal" but I had a hard time modifying it to keep the error in this form.

maueroats commented 3 years ago

This is more like a minimal example. The test fails with unbound identifier. The two hyperlinks go to the same place, which I think is undesirable.

#lang racket
(require (for-syntax syntax/parse))
(require test-engine/racket-tests)

(define-syntax check-question
  (syntax-parser
    [(_ e)
     #'cond-QA]))

"notice that both lines are linked to the same place"

(check-expect (check-question whatever)
              #true)

(test)
shhyou commented 3 years ago

Should this issue be transferred to racket/htdp?

I found another program that has similar behavior. In this program, both of the hyperlinks highlighted the empty application expression () where one of the hyperlink should have pointed to the entire test.

;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "htdp-intermediate-lambda-reader.ss" "lang")((modname te) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))

(check-expect ()
              #true)

BTW, here is the fix for the particular syntax error that you are seeing:

(module stx racket/base
  (require syntax/parse
           ;; Here, because when `stx` is instantiated at phase 1,
           ;; there is no phase 0 binding for #%datum.
           ;;
           ;; To see this, change #'#true to #'(quote #true) and the error
           ;; message will become 'quote: unbound identifier'.
           (for-template racket/base))
  (provide cond-QA)
  (define-syntax-class cond-QA
    (pattern [#:else answer]
             #:attr question #'#true)))
shhyou commented 3 years ago

I've transferred this issue to racket/htdp as the Test Engine is part of HtDP.

mfelleisen commented 3 years ago

@rmculpepper The program causes a strange error in the macro stepper. It seems internal.