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

Use errortrace-key instead of DrRacket's own key. #679

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mikesperber
Copy link
Member

This is so we can pick it up in the teaching languages for reporting error locations.

As discussed with Robby at ICFP.

This is so we can pick it up in the teaching languages for
reporting error locations.
@mikesperber
Copy link
Member Author

(The ensuing changes in htdp-lib and deinprogramm are ready to go.)

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Resyntax analyzed 6 files in this pull request and found no issues.

@rfindler
Copy link
Member

rfindler commented Sep 7, 2024

Mike and I just talked in person about this -- this may be the best (only?) way to make this change, but it is possible that DrRacket can avoid instantiating the errortrace unit entirely and just use various the handlers from errortrace directly. It is also possible that DrRacket has to instantiate the unit itself for some reason but, if so, it would be good to be sure that the information that's put into the marks is all in the same format as what errortrace does, to make other uses of that information just work.

@mfelleisen
Copy link
Contributor

mfelleisen commented Sep 7, 2024 via email

@mikesperber
Copy link
Member Author

... but it is possible that DrRacket can avoid instantiating the errortrace unit entirely and just use various the handlers from errortrace directly. It is also possible that DrRacket has to instantiate the unit itself for some reason but, if so, it would be good to be sure that the information that's put into the marks is all in the same format as what errortrace does, to make other uses of that information just work.
We talked again: DrRacket does more than errortrace-lib, so we can't quite use it. But I'll indeed need to adjust the format of the continuations marks.

@mikesperber
Copy link
Member Author

@rfindler Could you take another look?

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Resyntax analyzed 6 files in this pull request and found no issues.

@rfindler
Copy link
Member

The drracket tests seem to pass.

The word "alligned" isn't spelled right. And probably that comment could be clearer.

We probably also need a test case. The test probably should ensure that the format of the marks is the same as errortrace's format by requiring errortrace and calling a function.

Here's some code that passes when run at the command-line with errortrace enabled and fails when it doesn't. How does that look as the start of a test case for drr?

#lang racket
(require errortrace/errortrace-lib
         errortrace/errortrace-key)
(define exn
  (with-handlers ([exn:fail? values])
    (define (f x) (unless (zero? x) (+ (f (- x 1)))))
    (set! f f)
    (f 10)))

(define sp (open-output-string))
(parameterize ([current-error-port sp])
  (errortrace-error-display-handler "abc" exn))

(unless (< 10 (length (continuation-mark-set->list (exn-continuation-marks exn)
                                                   errortrace-key)))
  (error 'errortrace-test "failed.1"))

(define lines
  (for/fold ([in-good-region? #f]
             [stacktrace-lines '()]
             #:result stacktrace-lines)
            ([line (in-lines (open-input-string (get-output-string sp)))])
    (cond
      [(regexp-match? #rx"^ *errortrace" line)
       (values #t '())]
      [(regexp-match? #rx"^ *context" line)
       (values #f stacktrace-lines)]
      [else
       (values in-good-region?
               (if in-good-region? (cons line stacktrace-lines) stacktrace-lines))])))
(unless (< 10 (length lines))
  (error 'errortrace-test "failed.2"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants