htdp icon indicating copy to clipboard operation
htdp copied to clipboard

Test engine links incorrect source location for check-expects in REPL

Open shhyou opened this issue 1 year ago • 7 comments

The test engine source hyperlinks are not working for check-expects in REPL.

;; Unsaved editor
#lang htdp/isl+

;; -> Run
Welcome to DrRacket, version 8.15.0.2 [cs].
Language: htdp/isl+, with debugging; memory limit: 128 MB.
> (check-expect (+ 2 3) 6)
Ran 1 test.
0 tests passed.

Check failures:
        Actual value 5 differs from 6, the expected value.
at line 3, column 2

;; -> Click on "at line 3, column 2"

Expected behavior: highlight the failing check-expect Actual behavior:

  • ~~In a saved editor: nothing happened~~ also got the error message
  • In an unsaved editor: got error message:
send: no such method
  method name: get-tab
  class name: test-interactions-text%-mixin175
  context...:
   <collects>/racket/private/class-internal.rkt:4730:0: obj-error
   <pkgs>/framework/private/srcloc-snip.rkt:36:2: show-editor
   <pkgs>/framework/private/srcloc-snip.rkt:20:4: frame-loop
   <pkgs>/mred/private/wxme/text.rkt:537:2: on-default-event method in text%
   <pkgs>/mred/private/wxme/editor-canvas.rkt:412:2: on-event method in editor-canvas%
   <collects>/racket/private/more-scheme.rkt:148:2: call-with-break-parameterization
   <collects>/racket/private/more-scheme.rkt:266:2: call-with-exception-handler
   <pkgs>/mred/private/wx/cocoa/window.rkt:899:4: dispatch-on-event method in window%
   <pkgs>/mred/private/wx/common/queue.rkt:436:6
   <pkgs>/mred/private/wx/common/queue.rkt:487:32
   <pkgs>/mred/private/wx/common/queue.rkt:639:3

shhyou avatar Oct 26 '24 16:10 shhyou

@rfindler

i know this investigation but the meta-error message about get-tab seems to suggest this is a miscommunication among some drracke comments.

mfelleisen avatar Oct 26 '24 19:10 mfelleisen

I'm having trouble reproducing the error. It seems like, when I create a new frame and don't hit Run the button (but because the language was already set I'll have a REPL) and then I evaluate a failing check-expect, I get a nearby error, but it seems to happen on the line after the one in @shhyou 's report (below).

Is it possible I'm missing a step to reproduce?

send: target is not an object
  target: #f
  method name: get-frame
  context...:
   /Users/robby/git/plt/racket/collects/racket/private/class-internal.rkt:4730:0: obj-error
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/framework/private/srcloc-snip.rkt:36:2: show-editor
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/framework/private/srcloc-snip.rkt:20:4: frame-loop
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/mred/private/wxme/text.rkt:537:2: on-default-event method in text%
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/mred/private/wxme/editor-canvas.rkt:412:2: on-event method in editor-canvas%
   /Users/robby/git/plt/racket/collects/racket/private/more-scheme.rkt:148:2: call-with-break-parameterization
   /Users/robby/git/plt/racket/collects/racket/private/more-scheme.rkt:266:2: call-with-exception-handler
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/mred/private/wx/cocoa/window.rkt:899:4: dispatch-on-event method in window%
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/mred/private/wx/common/queue.rkt:436:6
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/mred/private/wx/common/queue.rkt:487:32
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/mred/private/wx/common/queue.rkt:639:3

rfindler avatar Oct 26 '24 21:10 rfindler

Does this change make a difference?

diff --git a/gui-lib/framework/private/srcloc-snip.rkt b/gui-lib/framework/private/srcloc-snip.rkt
index ee6cbd17..92ca4308 100644
--- a/gui-lib/framework/private/srcloc-snip.rkt
+++ b/gui-lib/framework/private/srcloc-snip.rkt
@@ -33,7 +33,11 @@
             [else
              (frame-loop (cdr frames))])))))
 
-  (define (show-editor frame editor)
+  (define (show-editor frame _editor)
+    (define editor
+      (if (method-in-interface? 'get-definitions-text (object-interface _editor))
+          (send _editor get-definitions-text)
+          _editor))
     (let* ([current-tab (send editor get-tab)]
            [frame (send current-tab get-frame)])
       (let loop ([tabs (send frame get-tabs)] [i 0])

rfindler avatar Oct 26 '24 21:10 rfindler

Also, as I'm looking at this code, it does seem a little weird. It definitely expects that DrRacket-specific methods are existing on the frame but it is part of the framework. So probably it should either move into DrRacket somehow, or it should change to use only framework functionality (and check for that functionality's existence).

The latter option can't be done entirely, tho, because the framework doesn't have an equivalent of the highlight-error method on the interactions window. It may be possible to abstract over that functionality and pass in a function to the constructor of a srcloc snip that defaults to just, say, setting the position or something.

rfindler avatar Oct 26 '24 21:10 rfindler

I'm having trouble reproducing the error. It seems like, when I create a new frame and don't hit Run the button (but because the language was already set I'll have a REPL) and then I evaluate a failing check-expect, I get a nearby error, but it seems to happen on the line after the one in @shhyou 's report (below).

Is it possible I'm missing a step to reproduce?

I am using #lang based SLs. Menu-based SLs don't have this issue.

The latter option can't be done entirely, tho, because the framework doesn't have an equivalent of the highlight-error method on the interactions window. It may be possible to abstract over that functionality and pass in a function to the constructor of a srcloc snip that defaults to just, say, setting the position or something.

Meanwhile, highlighting after clicking the hyperlink is currently working in menu-based SLs. Can #lang based SLs use the same mechanism?

shhyou avatar Oct 27 '24 13:10 shhyou

So here's the configuration to reproduce the error:

  1. Language -> Choose Language -> Automatic #lang line:
    • Select _Always use the same #lang line: #lang racket/base
  2. TURN OFF the Graphical Debugger PLUGIN

The dependency on step 2 is totally unexpected!

shhyou avatar Oct 29 '24 19:10 shhyou

I pushed some changes that should help the situation here.

One difference: the highlights are now based on the selection, not using pink highlighting.

rfindler avatar Oct 29 '24 20:10 rfindler