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

Fix query-extract for vec #242

Merged
merged 2 commits into from
Oct 4, 2023
Merged

Conversation

hatoo
Copy link
Contributor

@hatoo hatoo commented Oct 1, 2023

Currently, query-extract for vec prints the reverse order of the argument

(sort IVec (Vec i64))

(let e (vec-of 1 2 3 4))
(query-extract e) ; => (vec-push (vec-push (vec-push (vec-push (vec-empty) 4) 3) 2) 1)

(check (= e (vec-push (vec-push (vec-push (vec-push (vec-empty) 4) 3) 2) 1))) ; fail

This PR fixes it and prints by vec-of

(sort IVec (Vec i64))

(let e (vec-of 1 2 3 4))
(query-extract e) ; => (vec-of 1 2 3 4)
(query-extract (vec-empty)) ; => (vec-empty)

(check (= e (vec-of 1 2 3 4))) ; OK

- Use "vec-of" instead of list of vec-push to better readability
@hatoo hatoo requested a review from a team as a code owner October 1, 2023 09:51
@hatoo hatoo requested review from oflatt and removed request for a team October 1, 2023 09:51
Copy link
Member

@oflatt oflatt left a comment

Choose a reason for hiding this comment

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

Good catch!

Copy link
Member

@oflatt oflatt left a comment

Choose a reason for hiding this comment

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

Great catch, could you please also add a repro test for this?

@hatoo
Copy link
Contributor Author

hatoo commented Oct 3, 2023

Added.
I'm not sure it's the best way to test this though.

Copy link
Member

@oflatt oflatt left a comment

Choose a reason for hiding this comment

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

Thanks!

@oflatt oflatt merged commit 3c89b7c into egraphs-good:main Oct 4, 2023
3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants