greg
2021-6-9 17:18:01

@xlambein Also keep in mind that ... means zero or more. Instead you might want ...+ which means one or more.: https://docs.racket-lang.org/syntax/stxparse-patterns.html#%28form._%28%28lib._syntax%2Fparse..rkt%29._......%2B%29%29


greg
2021-6-9 17:18:26

IIRC ...+ is only available from syntax-parse.


jjsimpso
2021-6-9 17:39:49

While using racket/gui I’ve noticed that some runtime contract errors often don’t get printed. It seems to happen when the error occurs while instantiating a class. Any idea what is happening here? It makes it somewhat difficult to debug simple runtime errors. I’m using racket-mode and these messages would normally be printed to the REPL buffer.


greg
2021-6-9 17:48:31

Off the top of my head I’m not sure. Would it be possible for you to give me e.g. a single .rkt file example that, when run, shows the problem? (I mean, causes a runtime error, but you don’t see any error message displayed.)


greg
2021-6-9 17:51:56

Also what do you have (in Emacs) for racket-error-context? If it is low or medium, does the problem go away if you choose high? Or vice versa?


greg
2021-6-9 18:42:59

I tried this: #lang racket/gui (define frame (new frame% [label 9999999999999] [height 512] [width 512])) which is not a syntax error but is a runtime error.


greg
2021-6-9 18:43:07

I do see an error message.


greg
2021-6-9 18:43:32

(regardless of the racket-error-context value, so that idea of mine was n/a)


greg
2021-6-9 18:43:47

I guess I’ll need an example from you and/or some more information.


greg
2021-6-9 18:43:54

@jjsimpso


greg
2021-6-9 18:45:26

p.s. the error message I see is e.g. ; initialization for frame%: contract violation ; expected: label-string? ; given: 9999999999999 ; Context (errortrace): ; /var/tmp/gui.rkt:3:14: (do-make-object lifted/1 frame% (list) (list (cons (quote ....) (....)) (cons (....) ....) (cons ....))) displayed in the racket-repl-mode buffer


greg
2021-6-9 18:47:00

Maybe you could M-x racket-bug-report (that will includes some configuration settings you have) and a simple example?


jjsimpso
2021-6-9 19:40:14

@greg, it may take me some time to construct a minimal example. In general I do see contract errors from my GUI app in the repl buffer.


greg
2021-6-9 19:44:04

Ultimately I might need a minimal-ish example to be able to reproduce and fix. If that’s tough for you, meanwhile it might also be helpful to try the thing I suggested above with racket-error-context. e.g. If it’s medium, set it to high (or vice versa) then try again and see if the error is displayed or not.


greg
2021-6-9 19:44:48

Those are somewhat different paths, including but not limited to using errortrace-lib or not. Knowing which path is problemmatic might help me narrow it down and guess — maybe even be able to come up with the minimal example myself.


greg
2021-6-9 19:44:59

Or some other idea how to fix.


greg
2021-6-9 19:47:01

Another idea: If you can make the error display in the plain old REPL, then copy/pasting that exact error message text for me, might also give me a clue. (As one wild guess: If the error lacks any srcloc, e.g. no line:col info, that might be how/why it’s getting filtered — at least for one of the racket-error-context value paths.)


greg
2021-6-9 19:50:17

(sorry, I know you’re just trying to write and debug your own program… not also mine :disappointed:)


jjsimpso
2021-6-9 20:00:34

@greg, ok I have a minimal example. And in drracket it does print the error messages. #lang racket/gui (define download-list '("file1" "file2")) (define download-panel% (class horizontal-panel% (inherit popup-menu) (define/override (on-subwindow-event receiver evt) (cond [(send evt button-down?) (eprintf "dl = ~a~n" download-list) (let ([menu (new popup-menu% [title "Download List"] [popdown-callback (lambda (pm ce) void)])]) (for ([dl (in-list download-list)]) (new menu-item% [parent menu] [label 999] ; if I change to [label 999] I don't see a contract error message [callback (lambda (x y) (eprintf "cancelling ~a~n" dl))])) (popup-menu menu 0 0)) #t] [else (super on-subwindow-event receiver evt)])) (super-new))) (define frame (new frame% [label "test"] [height 512] [width 512])) (define download-status (new download-panel% (parent frame) (border 2) (stretchable-width #f) (stretchable-height #f))) (define download-button (new button% (parent download-status) (label "Downloads") (stretchable-width #f))) (send frame show #t)


jjsimpso
2021-6-9 20:01:04

Clicking the button will generate a contract violation.


jjsimpso
2021-6-9 20:02:16

In the simple example of just a frame like you tried above, I do see the contract error message in the racket-mode repl. So something about the more complex example is causing this.


jjsimpso
2021-6-9 20:17:06

This is the error I see in drracket: initialization for menu-item%: contract violation expected: label-string? given: 999


greg
2021-6-9 20:21:13

Thank you! I get same result. Now to figure out what’s going on…


jjsimpso
2021-6-9 20:23:30

Thank you! I haven’t tried setting the racket-error-context since I can’t figure out how, i’m embarrassed to admit.


jjsimpso
2021-6-9 20:24:20

I did try ‘C-u F5’ to run my example and that didn’t change anything.


greg
2021-6-9 20:43:53

I created an issue for this: https://github.com/greghendershott/racket-mode/issues/543. I didn’t tag you there b/c I don’t know if you’re on GitHub and/or if you want to be tagged publicly.


greg
2021-6-9 20:44:58

I looked into a few “obvious” ideas but none panned out. I may need to tackle this tomorrow with a fresher brain.


jjsimpso
2021-6-9 20:46:23

Thanks for taking a look. I subscribed to the bug.