DioxusLabs/dioxus · error

Invalid Option type

Error message

Invalid Option type

What it means

While mapping a foreign type in the FFI bridge macro, an Option<...> type was used whose inner generic arguments are not one of the supported FFI types, so the corresponding foreign (Swift/Kotlin) optional type cannot be derived.

Solutions

  1. Use a plain `Option<T>` with a supported inner type in the FFI signature; nested or non-standard option types are not supported.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/manganis/manganis-macro/src/ffi.rs:81 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/c1a0f25e89a08b46. Report an issue: GitHub.

Appendix: source

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

                        "i8" => return Ok(ForeignType::I8),
                        "i16" => return Ok(ForeignType::I16),
                        "i32" => return Ok(ForeignType::I32),
                        "i64" => return Ok(ForeignType::I64),
                        "u8" => return Ok(ForeignType::U8),
                        "u16" => return Ok(ForeignType::U16),
                        "u32" => return Ok(ForeignType::U32),
                        "u64" => return Ok(ForeignType::U64),
                        "f32" => return Ok(ForeignType::F32),
                        "f64" => return Ok(ForeignType::F64),
                        "String" => return Ok(ForeignType::String),
                        "Option" => {
                            if let syn::PathArguments::AngleBracketed(args) = &segment.arguments
                                && let Some(syn::GenericArgument::Type(inner)) = args.args.first()
                            {
                                let inner_type = Self::from_type(inner)?;
                                return Ok(ForeignType::Option(Box::new(inner_type)));
                            }
                            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"));

View on GitHub (pinned to 24f6a829df)