We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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 constructing a function with a ref argument and an argument exclusivity issue, the compiler gives a misleading error message.
Consider the folloeing code:
@value struct MyElement: var a: Int struct MyType: var a: Int var l: List[MyElement] fn __init__(inout self, a: Int): self.a = a self.l = List[MyElement]() fn do(inout self, ref[self.l] e: MyElement, b: Int): e.a = b self.a = b fn main(): t = MyType(1) t.l.append(MyElement(1)) t.do(t.l[0], 1)
Here, do should be invalid, as it violates argument exclusivity. However, the compiler errors with
do
error: invalid call to 'do': method argument #0 cannot be converted from 'MyElement' to 'Reference['MyElement', ...] t.do(t.l[0], 1) ~~~~^~~~~~~~~~~ note: operand origin 't.l' doesn't match expected origin '*[0,0].l' t.do(t.l[0], 1) ^ function declared here fn do(inout self, ref[self.l] e: MyElement, b: Int): ^ mojo: error: failed to parse the provided Mojo source module
- Ubuntu 22.04.5 in WSL 2 on Windows 10 - mojo 24.6.0.dev2024120105 (78dab9b8) - magic 0.4.0 - (based on pixi 0.33.0)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Bug description
When constructing a function with a ref argument and an argument exclusivity issue, the compiler gives a misleading error message.
Steps to reproduce
Consider the folloeing code:
Here,
do
should be invalid, as it violates argument exclusivity. However, the compiler errors withSystem information
- Ubuntu 22.04.5 in WSL 2 on Windows 10 - mojo 24.6.0.dev2024120105 (78dab9b8) - magic 0.4.0 - (based on pixi 0.33.0)
The text was updated successfully, but these errors were encountered: