racket / drracket

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

Arrays in syntax parse template seem wrong #403

Closed pmatos closed 4 years ago

pmatos commented 4 years ago

Run:

#lang racket/base

(require (for-syntax racket/base syntax/parse))

(define-syntax (f stx)
  (syntax-parse stx
    #:track-literals
    #:datum-literals (& = xx)
    [(_ k:exact-positive-integer n:exact-nonnegative-integer)
     #'(* 2 n k)]
    [(_ _ (xx n:exact-nonnegative-integer k:exact-positive-integer))
     #'(* 3 n k)]
    [(_ k:exact-positive-integer name:id)
     #'(string-length (string-append (symbol->string 'name) (number->string k)))]
    [(_ k:exact-positive-integer (& a:expr ...+))
     #'(min (f k a) ...)]
    [(_ k:exact-positive-integer (= a:expr ...+))
     #'(max (f k a) ...)]))

Press Run (version 7.8 both BC and CS), and see the arrows for k in the last couple of patterns actions. They seem to be wrong. Here's a screenshot.

2020-08-05-074704_1089x501_scrot

pmatos commented 4 years ago

Please let me know if this is not the right place for this bug. First time I see a problem in this area so unsure if it belongs here on in racket/racket.

sorawee commented 4 years ago

It's the same as racket/racket#1875 I think?

pmatos commented 4 years ago

It's the same as racket/racket#1875 I think?

You're right. Totally confusing in this example because there doesn't seem, at first glance, why it would point to the third pattern k and not, let's say, the first k

Anyway, I will close this as a dup.

Duplicate of https://github.com/racket/racket/issues/1875 @mflatt please reopen if you don't think that's the case.