Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistent/undocumented behaviors of ellipsis in quasi-patterns for match #3850

Open
capfredf opened this issue May 24, 2021 · 1 comment

Comments

@capfredf
Copy link
Sponsor Member

What version of Racket are you using?
8.1.0.5

What program did you run?

> (match '(abc)
    [`(abc ...) 42])
42

> (match '(abc)
    [`(,@(list abc)) 42])
42

> (match '(abc)
    [`(,@(list abc) ...) 42])
; match: no matching clause for '(abc) [,bt for context]

> (match '(abc ...)
    [`(,@(list abc) ...) 42])
42

What should have happened?
The third match expression above should have worked, whereas the last one should have not.

Discussion
According to the reference, (,@(list abc) ...) should be treated like abc repeats zero or more times, but ... in this pattern is treated like literal ....

@sorawee
Copy link
Collaborator

sorawee commented May 25, 2021

Perhaps this is the same bug above, but it could also be different.

(match '(1 1 1)
  [`(,@xs) xs]) 
; '(1 1 1) -- correct

(match '(1 1 1 ...)
  [`(,@xs ...) xs])
; '(1 1 1) -- incorrect because ... shouldn't be matched literally

(match '(1 1 1 ... ...)
  [`(,@xs ... ...) xs])
; '(1 1 1 ... ...) -- what's going on?!?

(match '(1 1 1 ... ... ...)
  [`(,@xs ... ... ...) xs])
; '(1 1 1 ... ...)

(match '(1 1 1 ... ... ... ...)
  [`(,@xs ... ... ... ...) xs])
; '(1 1 1 ... ... ... ...)

@capfredf capfredf changed the title inconsistent behaviors of ellipsis in quasi-patterns for match inconsistent/undocumented behaviors of ellipsis in quasi-patterns for match May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants