-
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] candidate not viable: argument #0 cannot be converted from 'Set[Int]' to 'Set[Int]' #3708
Comments
I suspect this is a generic type-checking bug. If you try a memory-only type wrapper workaround like in mojo/stdlib/src/builtin/sort.mojo Line 34 in 5babce6
MemoryOnlyWrapper could be generalized.
|
@JoeLoser I don't think it's reg-type causing problem here. Somehow @value
struct S[T: KeyElement]:
...
fn f[T: BoolableKeyElement](set: S[T]) -> Bool:
return False
fn g[T: KeyElement](set: S[T]) -> Bool:
return False
fn main():
s = S[Int]()
f(s) # invalid call to 'f': argument #0 cannot be converted from 'S[Int]' to 'S[Int]'
g(s) Update: no longer reproduce on |
FYI, I tried this out just now and the example directly above appears to be fixed. Can you take a look to see if this is still broken, and if so, include an updated small example? Thanks! |
@mzaks I tried rebasing your PR onto nightly, and the original problem does seem to have gone away. |
@lattner Sadly the bug is not resolved yet, I kept two failing statements around in my PR branch Would this be enough for the team to easily reproduce the error? I can try to write a smaller example, but I think it is not that trivial as it seems to be related to the |
Actually, I think Joe was right and it might be reg-type related after all. trait T1:
fn __hash__[H: AnyType](self):
...
trait T2(T1):
pass
@register_passable("trivial") # comment this line out and the problem goes away
struct I(T1):
fn __hash__[H: AnyType](self):
pass
@value
struct S[T: T1]:
...
fn f[U: T2](self: S[U]):
...
fn main():
s = S[I]()
f(s) |
Yes, I think that is likely to be the root of it. We have some logic that tries to make regpassable trivial types conform to copyable/anytype etc by using a wrapper struct |
Bug description
This bug is a blocker for PR #3701
It is a compiler bug where compiler can't identify that
assert_true(any(Set(-1)))
should pickfn any[T: BoolableKeyElement](set: Set[T]) -> Bool:
function. It the compiler tellscandidate not viable: argument #0 cannot be converted from 'Set[Int]' to 'Set[Int]'
Full Error log:
Steps to reproduce
See PR #3701 you can uncomment lines followed by marker
# TODO: this was working before
System information
The text was updated successfully, but these errors were encountered: