-
Notifications
You must be signed in to change notification settings - Fork 214
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
Custom Types using bytes
lead to duplicate declarations in bindings
#1651
Comments
I added your example as a regression test here: e9193ca I'm getting a different error though:
So something else already changed, not necessarily for the better though |
Ah yes, I forgot to mention that I also tried the git version and I was getting such an error, preventing me from producing any kind of meaningful result beyond a panic trace :/ |
That assertion was part of 044b85d |
There are (at least) 2 things going wrong here:
(ie, it's now an error rather than generating the dupes) but it's the same underlying problem. I'm really not sure how to solve that second problem - I think it's clear that the procmacro code and udl code in the same crate need to agree on what various names are, but I'm not sure how exactly. When build.rs is being run as don't actually know what the crate name actually is. I think it might be necessary to introduce a new 1 It's not even clear to me it's the crate name - there are other examples which can demonstrate it must match the lib name rather than the package name, which also confuses me - but in this particular example those 2 names do indeed match, so that's not directly relevant here. |
I'm actually not sure how to proceed here. procmacros simply have no concept of bytes and I'm not sure how it should learn about them. Eg, it's impossible to export a fn which takes |
I think #1638 might be the way forward. I'm not very versed in proc_macros in general but it might be possible through forcing the type in proc macros to force disambiguation. Because yeah, I see the issue. Either there are drastic changes in how UniFFI computes types (i.e. struct declarations are processed before functions/methods and cannot be replaced from refs in functions) or we could let the user sort out the conflicts themselves by steering the proc macros in the right direction. Also, very honestly, I don't see any use case where |
Hi!
We just came across an issue where if you have a Custom type that is typealiased to the new
bytes
AND it appears in function parameters / other structs, UniFFI will default to an equivalent tosequence<u8>
and emit a double declaration of the custom type in the generated bindings.This affects all binding target languages (I tested Swift, Kotlin and Python, all are affected).
I setup a minimal repro repository over here: https://github.com/OtaK/uniffi-custom-bug
Cheers,
The text was updated successfully, but these errors were encountered: