racket / drracket

DrRacket, IDE for Racket
http://www.racket-lang.org/
Other
447 stars 94 forks source link

Syntax Source is Different when Running Inside DrRacket [cs] #455

Closed shhyou closed 3 years ago

shhyou commented 3 years ago

I am not sure if this is a DrRacket issue or a Racket issue.

Version: (Dr)Racket 7.9.0.22 [cs]

Example program:

#lang racket/base
(syntax-source (quote-syntax here))

When running from the command line, the result is an absolute path:

$ racket stxsrc.rkt 
#<path:/Volumes/ramdisk/stxsrc.rkt>

When running inside DrRacket [cs] without errortrace but with background expansion, the result is a relative path:

Welcome to DrRacket, version 7.9.0.22 [cs].
Language: racket/base [custom]; memory limit: 512 MB.
#<path:stxsrc.rkt>
> 

This difference does not show up in Racket v7.9 [bc]. Subsequently, the path difference affects error location highlighting because set-error-ranges relies on port-name-matches?. (related to https://github.com/racket/racket/issues/3325#issuecomment-752354258) https://github.com/racket/drracket/blob/6cda6a7b1738b0be624f96aba10c48b1e5adbe4d/drracket/drracket/private/rep.rkt#L637-L644.

sorawee commented 3 years ago

Also looks related to #421?

shhyou commented 3 years ago

Yes! Looks like they are the same bug. Turning off background expansion does side-step this and fixes the voldemort problem.

mflatt commented 3 years ago

It looks like this is fixed along with #421, so I'll close (but reopen if I have it wrong).

sorawee commented 3 years ago

Let me reopen this since there's one more case that differs: unsaved editor.

In DrRacketCS:

#lang racket/base
(syntax-source (quote-syntax here))

outputs "unsaved editor". In DrRacketBC, it outputs 'unsaved-editor.

The difference seems to cause the voldemort example to fail.

shhyou commented 3 years ago

looks like an easily fix here or in the gui library

racket/share/pkgs/drracket/drracket $
private/expanding-place.rkt:118:  (define the-source (or path "unsaved editor"))
racket/share/pkgs/gui-lib $
framework/private/text-basic.rkt:527:      (define port-name-unsaved-name "unsaved-editor")
sorawee commented 3 years ago

Why are BC and CS evaluate differently though? It looks like there's a larger problem behind this bug.

shhyou commented 3 years ago

I tested 8.0.0.3 [cs] and 7.9 [3m] with background expansion enabled and errortrace disabled. The results are both "unsaved editor". With errortrace, the outputs both become 'unsaved-editor. Either case, voldemort is highlighted with the above patch.

Is this what you see too?

sorawee commented 3 years ago

It's complicated. I can see the behavior that you described, but also don't see the behavior that you described under some circumstance.

  1. Right after switching errortrace off, in DrRacketCS, the output is sometimes still 'unsaved-editor. Sometimes it's "unsaved editor" right away. In any case, after one more run, they both produce "unsaved editor".
  2. But unfortunately for voldemort, I can see the behavior that you described (that it works when errortrace is off in DrRacketCS) only once. After that, it consistently fails to highlight, regardless of many times I run the program.
sorawee commented 3 years ago

Based on my experiments, I'm pretty sure voldermort works if and only if it outputs 'unsaved-editor.

I can now consistently reproduce the problem:

  1. Assume that in the current setting, errortrace is off.
  2. Open a new tab. Running the program should produce "unsaved editor".
  3. Switch errortrace to on. Running the program should produce 'unsaved-editor.
  4. Switch errortrace to off. Running the program should produce 'unsaved-editor.
  5. Running it again should produce "unsaved editor". Any subsequent run will produce "unsaved editor". Even if you switch errortrace on and then off again, it will still produce "unsaved editor". This current buffer is doomed. Open a new tab will let you repeat from step 0 again.
sorawee commented 3 years ago

Aha! The fact that voldemort doesn't work is a bug in Racket BC as well!

Somehow this bug seems to manifest more in Racket CS, though.

mflatt commented 3 years ago

@sowaree If you're running AArch64 BC, then you're running without places. That may have more to do with things than CS vs. BC, although I'm not certain. You could use x86_64 BC to avoid that difference.

mflatt commented 3 years ago

Also, I'm not sure it's clear (because I may have overlooked some discussion): when you have a star-ish dot in the bottom right in DrRacket, that means you're running the result of background expansion directly. A smooth-circle dot means that "Run" starts over independent of background expasion (e.g., to add debugging information). So, you might be getting different results depending on whether the dot has gone green and star-ish.

sorawee commented 3 years ago

Yep, I'm running AArch64 BC. I can try x86_64 BC when I get a chance to install it.

Re background expansion: you are totally right about it. That's the cause of difference.

rfindler commented 3 years ago

Those two commits seem to fix the volemort program in the spiky ball state.

sorawee commented 3 years ago

Yes, it works now. Thanks! :)