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

More consistently report problems with non-linear patterns. #2231

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

samth
Copy link
Sponsor Member

@samth samth commented Aug 16, 2018

Also document limitation, and suggest a fix.

Closes #1386 Closes #2152

Also document limitation, and suggest a fix.

Closes racket#1386
Closes racket#2152
@lexi-lambda
Copy link
Member

I like these documentation changes. The code changes seem to have broken a test, however.

@samth
Copy link
Sponsor Member Author

samth commented Aug 17, 2018

Yes, the code changes are a bit too aggressive. I have to figure out how to make it less so, but it's not totally obvious.

@samth
Copy link
Sponsor Member Author

samth commented Jun 28, 2022

@AlexKnauth this is relevant to #4304

@AlexKnauth
Copy link
Member

While working on #4304 I found that just erroring when nonlinear patterns are detected via the seen list, is not enough to catch many nonlinear patterns that should be errors.

For example, I would like

(match '(1 2 3 4)
  [(list a ... a) a])

to be an error, but the renaming of a interferes with the seen lookup.

@@ -175,16 +177,21 @@
(and (bound-identifier=? v v*) (or id (list v v*)))))
=>
(lambda (id)
(if (identifier? id)
(if (and (identifier? id) (not (inside-GSeq?)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (not (inside-GSeq?)) check also doesn't allow nonlinear patterns inside the "tail" of GSeq patterns, such as in (list a _ ... a) and (cons a (list pre ... a post ...)).

That seems too restrictive to me. In my opinion it should be restricted based on the pattern itself being under ellipses, not based on it being in the tail after something else that's under ellipses.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. This PR is too aggressive as I said at the time, but I didn't settle on a better fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants