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

Deep list pattern match does not backtrack correctly #565

Open
msteindorfer opened this issue Apr 30, 2014 · 2 comments
Open

Deep list pattern match does not backtrack correctly #565

msteindorfer opened this issue Apr 30, 2014 · 2 comments
Assignees

Comments

@msteindorfer
Copy link
Member

The following two examples should produce the same output:

rascal>[ v | [_*,/v,_*] := [[1,2], [3,4]]]
list[int]: [1,2,3]
rascal>[ v | [_*, x,_*] := [[1,2], [3,4]], /v := x];
list[value]: [
  1,
  2,
  [1,2],
  3,
  4,
  [3,4]
]

It seems that backtracking is not implemented correctly for deep list matching in the former case.

Deep set pattern matching does not exhibit the same problem:

rascal>{ v | {_*,/v,_*} := {{1,2}, {3,4}}}
set[value]: {1,2,4,{3,4},{1,2},3}
rascal>{ v | {_*, x,_*} := {{1,2}, {3,4}}, /v := x}
set[value]: {1,2,4,{3,4},{1,2},3}

I propose to also add regression tests for these different ways of deep pattern matching.

msteindorfer added a commit that referenced this issue Apr 30, 2014
See also #565 for information about the underlying cause.
@PaulKlint
Copy link
Member

Happy to report that the compiled version of the above pattern match does generate the correct answer.

@jurgenvinju
Copy link
Member

This goes wrong with more nested patterns which are not variables, also normal nodes apparently...

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

No branches or pull requests

3 participants