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

[When] Return inside of when statement produces counter-intuitive results #1258

Open
rsetaluri opened this issue Apr 3, 2023 · 1 comment
Assignees

Comments

@rsetaluri
Copy link
Collaborator

Code like

def my_mux(x, y, s):
    with m.when(~s):
        return x
    with m.otherwise():
        return y

produces counter-intuitive results.


We know per the spec that this is acts as expected, but it might be un-expected for the designer. Ideally, we would like to detect such code (and perhaps other similar cases) and raise a warning or error.

@leonardt
Copy link
Collaborator

The problem here is that the return control flow exits the code "prematurely" (w.r.t. the designer's desire). I'm not sure we can use the context manager cleanup pattern here to detect this undesired behavior, so I think the only mechanism here would be a linter.

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