DioxusLabs/dioxus · error

Invalid Result type

Error message

Invalid Result type

What it means

`ForeignType::from_type` parses a `Result<T, E>` in an FFI signature and errors when the Result's generic arguments cannot be resolved to exactly two types. A malformed Result type (wrong arity or unsupported arguments) in a Swift/Kotlin bridge function triggers this compile error.

Solutions

  1. Use a plain `Result<T, E>` with supported types in the FFI signature; other result-like types are not supported.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/manganis/manganis-macro/src/ffi.rs:99 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/a22fb8d0f9032168. Report an issue: GitHub.

Appendix: source

Thrown at packages/manganis/manganis-macro/src/ffi.rs:99

                            return Err(syn::Error::new(ty.span(), "Invalid Option type"));
                        }
                        "Result" => {
                            if let syn::PathArguments::AngleBracketed(args) = &segment.arguments {
                                let mut iter = args.args.iter();
                                if let (
                                    Some(syn::GenericArgument::Type(ok_ty)),
                                    Some(syn::GenericArgument::Type(err_ty)),
                                ) = (iter.next(), iter.next())
                                {
                                    let ok_type = Self::from_type(ok_ty)?;
                                    let err_type = Self::from_type(err_ty)?;
                                    return Ok(ForeignType::Result(
                                        Box::new(ok_type),
                                        Box::new(err_type),
                                    ));
                                }
                            }
                            return Err(syn::Error::new(ty.span(), "Invalid Result type"));
                        }
                        _ => {
                            // Assume it's an opaque type reference
                            return Ok(ForeignType::OpaqueRef(segment.ident.clone()));
                        }
                    }
                }
                Err(syn::Error::new(ty.span(), "Unsupported type path"))
            }
            Type::Reference(type_ref) => {
                if let Type::Path(path) = &*type_ref.elem {
                    if path.path.is_ident("str") {
                        return Ok(ForeignType::StrRef);
                    }
                    // Check for &OpaqueType
                    if path.path.segments.len() == 1 {
                        return Ok(ForeignType::OpaqueRef(path.path.segments[0].ident.clone()));
                    }

View on GitHub (pinned to 24f6a829df)