sorawee / fmt

A code formatter for Racket
Other
72 stars 6 forks source link

Possible bug added in commit: 08c49588a28153c920b5dafba22721e5a1f158a8 #17

Closed goldsteinn closed 2 years ago

goldsteinn commented 2 years ago

Hi, Just tried to get this working but ran into an error on HEAD.

$> raco make main.rkt

raco make main.rkt
core.rkt:94:1: define-syntax-parse-rule: unbound identifier
  in: define-syntax-parse-rule
  compilation context...:
   /home/noah/programs/libraries/racket-fmt/core.rkt
   /home/noah/programs/libraries/racket-fmt/main.rkt
  location...:
   core.rkt:94:1
  context...:
   do-raise-syntax-error
   for-loop
   [repeats 1 more time]
   finish-bodys
   lambda-clause-expander
   for-loop
   loop
   [repeats 23 more times]
   module-begin-k
   expand-module16
   expand-capturing-lifts
   temp118_0
   temp91_0
   compile15
   /usr/share/racket/collects/compiler/private/cm-minimal.rkt:414:0: compile-zo*58
   /usr/share/racket/collects/compiler/private/cm-minimal.rkt:705:15
   ...

Was able go back a few commits. It appears the first commit where I see the issue is: 08c49588a28153c920b5dafba22721e5a1f158a8

goldsteinn commented 2 years ago

FYI, wrote an elisp wrapper for this. Interested in PR?

sorawee commented 2 years ago

Hi! Thanks for letting me know of the problem.

So I think it's not a bug per se. It's likely that you have an old version of Racket that doesn't support define-syntax-parse-rule (which was added 10 months ago). Since it's easy to workaround, I will change it to avoid the error.

Can you tell me more about the elisp wrapper? How is it different from, say, format-all-the-code that is mentioned in #7?

Thanks again!

sorawee commented 2 years ago

Let me know if the current HEAD works for you. If so, I will close the issue.

Thanks!

goldsteinn commented 2 years ago

Got it :)

(should have updated my apt repo).

The elisp package is nothing special. Mostly written for personal use but figured I'd offer since I didn't see anything online. Its just cut and paste from yapfify template. format-all-the-code looks much better so if you can get your stuff in there that would certainly be best. (If you are interested in catering to emacs users a line start/end format option would be useful for formatting regions).

sorawee commented 2 years ago

FYI: in the latest commit I just made Racket 8.0 the minimal requirement, and switch back to define-syntax-parse-rule. This of course won't affect you as long as you don't upgrade the package. But if you do, you need to upgrade the Racket version as well for it to work.