-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[BUG] Compiler bug of walrus operator with multiple and
s
#2783
Comments
I don't think this one is a bug. It looks trivial in this particular case, but in general the compiler can't prove that |
In general, for |
Regardless it's valid Python code so if possible it must work in Mojo as well. |
That's a bigger problem. Python would raise a run-time error and mojo is doing some compile-time checks. Note that the current compiler already know |
I meant that exact code runs successfully with no issue (however obviously it fails if you use and |
Yeah it's a serious issue if all valid python code with
|
I don't think that's correct. In a statement like fn f(b: Bool) -> Bool:
return ...
fn g(b: Bool) -> Bool:
return ...
def test():
if g((a := A) and f(b := B)): # f is opaque
print(a)
print(b) We can't guarantee that
Isn't it a good thing that a runtime error got turned into a compile time one? Anyhow, my point being that we can't support even the slightly more general case until full dict based dynamism. |
You changed my argument with evoking
Good if not buggy. |
@YichengDWu So you would agree that if it was |
It depends on the level of dynamism. |
|
Sorry there was a typo. Corrected:
|
and
s
and
s and
s
Bug description
Having multiple assignments in
if
orwhile
statement results in an errorSteps to reproduce
System information
The text was updated successfully, but these errors were encountered: