What version of Racket are you using?
7.9
What program did you run?
#lang racket/base
(require racket/match)
(match 'foo
['bar 'quux])
or any program where a match fails.
What should have happened?
If we run this with Racket BC, we get the following error info:
match: no matching clause for 'foo
location...:
match-error-example.rkt:3:0
context...:
But in Racket CS, the location part is missing:
match: no matching clause for 'foo
context...:
I guess I hadn't had match errors when using Racket CS before today (I only recently switched to defaulting to CS for most development), and I was surprised at the sudden lack of location information. I can imagine this was removed for Racket CS potentially as some kind of performance optimization, but I didn't see anything in the docs about it, or any way to re-enable it.
I'm frequently writing debug macros that give me more source information when an error is raised, and match was one macro that I never needed to do that with. Maybe this means I just don't know how to use debug tools like errortrace very well. But this error location from the match macro was super helpful.
match definitely isn't doing anything different on CS, so this is likely just a general CS vs BC issue.
matchdefinitely isn't doing anything different on CS, so this is likely just a general CS vs BC issue.
I thought that was probably the case. I guess for some reason I felt like I should make some kind of argument just in case this was an intentional change.
Can confirm the difference with this code:
#lang racket/base
(struct exn/loc exn:fail ()
#:property prop:exn:srclocs
(位 (e) (list (srcloc "source.rkt" 3 1 25 5))))
(raise (exn/loc "here" (current-continuation-marks)))
Racket v7.9 [bc]:
$ racket -v; racket srcl.rkt
Welcome to Racket v7.9 [bc].
here
location...:
source.rkt:3:1
context...:
"/Volumes/ramdisk/srcl.rkt": [running body]
Racket CS:
$ racket -v; racket srcl.rkt
Welcome to Racket v8.0.0.1 [cs].
here
context...:
/Volumes/ramdisk/srcl.rkt:7:0
body of "/Volumes/ramdisk/srcl.rkt"
I believe this is the same as #3325, but that issue is primarily focused on error message in DrRacket.
It's not obvious if the two are related or not. DrRacket preprocesses source locations before highlighting the editor, and it obtains source locations directly from the prop:exn:srclocs property. So the source location information is still there, but is dropped by the preprocessing function.
https://github.com/racket/drracket/blob/6cda6a7b1738b0be624f96aba10c48b1e5adbe4d/drracket/drracket/private/rep.rkt#L637-L644
In (define/public (highlight-errors raw-locs [raw-error-arrows #f]) ...):
raw-locs = (#(struct:srcloc #<path:exexns.rkt> 42 17 1302 9))
locs after (cleanup-locs raw-locs) = ()
Figured one difference for DrRacket:
In Racket CS, the source location is a relative path. In Racket v7.9 [bc], the source location is an absolute path:
However, this difference only appears when running from DrRacket.
(In Racket v7.9 [bc])
raw-locs = (#(struct:srcloc #<path:/Volumes/ramdisk/exexns.rkt> 42 17 1302 9))
locs after (cleanup-locs raw-locs) = (#(struct:srcloc #(struct:object:add-on-paint-logging ...) 42 17 1302 9));
I'm working on the prop:exn:srclocs problem.