Running some ellipsis patterns in define-judgment-form causes syntax error.
Open
Nobody has claimed this yet.
- Dominant language
- Racket
- Stars
- 112
- Forks
- 42
- PR merge metrics
- No merged PRs in 30d
Description
There is a small issue with the parsing of ellipsis patterns in define-judgment-form. The following file gets the error in racket 6.2. There are some observations about the pattern in the use and test cases.
#lang racket
(require redex)
(define-language L
(t ::= () (t ... -> t)))
(define-judgment-form L
#:mode (≈ I I)
#:contract (≈ t t)
[-------------------- "≈Refl"
(≈ () ())]
[(≈ t_1 t_2)
;; I have the intuition that this should be the same as
;; (≈* (τ_1 ...) (γ_1 ...))
(≈ t_n t_m) ...
------------------------------------------ "≈->"
(≈ (t_n ... -> t_1) (t_m ... -> t_2))
;; The following conclusion gets rid of this error.
#;(≈ (t_n ..._n -> t_1) (t_m ..._n -> t_2))])
(define-judgment-form L
#:mode (≈* I I)
#:contract (≈* (t ...) (t ...))
[--------- "≈*base"
(≈* () ())]
[(≈ t_1 t_2) (≈* (t_n ...) (t_m ...))
---------------------- "≈->"
(≈* (t_1 t_n ...) (t_2 t_m ...))])
(module+ test
(test-true (judgment-holds (≈ () ())))
(test-true (judgment-holds (≈ (-> ()) (-> ()))))
(test-true (judgment-holds (≈ (() -> ()) (() -> ()))))
(test-true (judgment-holds (≈ (() () -> ()) (() () -> ()))))
(test-false (judgment-holds (≈ () (-> ()))))
;; This test causes this pattern mentioned above to report
;; the following error.
;;syntax: incompatible ellipsis match counts for template in: ...
(test-false (judgment-holds (≈ (-> ()) (() -> ()))))
)
(module+ test (test-results))
;; Helpers to consider abstracting
(define-syntax-rule (test-true e)
(test-equal e #t))
(define-syntax-rule (test-false e)
(test-equal e #f))
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the embedded #lang racket reproduction and its module+ test cases, focusing on define-judgment-form ellipsis handling. The work is done when the final test-false case no longer raises the incompatible ellipsis match-count syntax error and the existing judgment tests still pass.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100