Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fixed visit_if for SymbolicCompare cases #2535

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

Merged
merged 1 commit into from
Feb 15, 2024
Merged

Conversation

anutosh491
Copy link
Collaborator

The way I addresssed #2532 is by creating a new If node instead of editing the m_test parameter of the old node itself and this works. I think the original code should itself be sufficient but we haven't been able to find the error hence using this.

I've added a test for the same.

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

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

I see what the issue is. Every visit statement method must return a new result in pass_result. If you don't, the statement gets skipped.

Consequently, I think the first two branches will also fail. In a subsequent PR, can you please write a test and fix them?

@certik certik merged commit 6098157 into lcompilers:main Feb 15, 2024
@anutosh491 anutosh491 deleted the if_1 branch February 16, 2024 10:48
@anutosh491
Copy link
Collaborator Author

Hmm, I think the first two branches do work. We can obviously get them changed but think about this.

Whenever we encounter an if block, something like if x == pi:

  1. We first transform/modify the if body through transform_stmts
  2. So once that is done, we don't need to add any new if stmt to pass_result
  3. Rather just make a change to the m_test field of the if statments .
  4. So if x == pi, changes to if basic_eq(x, pi): and the if body has been modified as per the pass too.

Well we have test_gruntz.py on master

def mmrv(e: S, x: S) -> list[S]:
    if not e.has(x):
        list0: list[S] = []
        return list0
    elif e == x:
        list1: list[S] = [x]
        return list1
    elif e.func == log:
        arg0: S = e.args[0]
        list2: list[S] = mmrv(arg0, x)
        return list2
    else:
        raise

which are based on the first two conditions we have. So I think we are doing fine, but just to get rid of any unwanted errors we can address this.

@certik
Copy link
Contributor

certik commented Feb 16, 2024

Ok. If it works then let it be. I am just surprised that the last case didn't work and I don't see how it is different to the previous two cases.

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

Successfully merging this pull request may close these issues.

2 participants