{"record":{"id":"32bcfaa7afead28c","repo":"DioxusLabs/dioxus","slug":"only-string-int-float-and-bool-literals-are-sup","errorCode":null,"errorMessage":"Only string, int, float, and bool literals are supported","messagePattern":"Only string, int, float, and bool literals are supported","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"packages/rsx/src/literal.rs","lineNumber":70,"sourceCode":"                quote! { dioxus_core::internal::HotReloadLiteral::Float(#f as _) }\n            }\n            HotLiteral::Int(f) => quote! { dioxus_core::internal::HotReloadLiteral::Int(#f as _) },\n            HotLiteral::Bool(f) => quote! { dioxus_core::internal::HotReloadLiteral::Bool(#f) },\n        }\n    }\n}\n\nimpl Parse for HotLiteral {\n    fn parse(input: ParseStream) -> syn::Result<Self> {\n        let raw = input.parse::<Lit>()?;\n\n        let value = match raw.clone() {\n            Lit::Int(a) => HotLiteral::Int(a),\n            Lit::Bool(a) => HotLiteral::Bool(a),\n            Lit::Float(a) => HotLiteral::Float(a),\n            Lit::Str(a) => HotLiteral::Fmted(IfmtInput::new_litstr(a)?.into()),\n            _ => {\n                return Err(syn::Error::new(\n                    raw.span(),\n                    \"Only string, int, float, and bool literals are supported\",\n                ));\n            }\n        };\n\n        Ok(value)\n    }\n}\n\nimpl ToTokens for HotLiteral {\n    fn to_tokens(&self, out: &mut proc_macro2::TokenStream) {\n        match &self {\n            HotLiteral::Fmted(f) => {\n                f.formatted_input.to_tokens(out);\n            }\n            HotLiteral::Float(f) => f.to_tokens(out),\n            HotLiteral::Int(f) => f.to_tokens(out),","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/rsx/src/literal.rs#L52-L88","documentation":"HotLiteral is the literal type dioxus serializes for hot-reload template diffing (packages/rsx literal.rs). Only integer, float, string, and bool literals are supported; other syn literal kinds such as char ('a') or byte-string (b\"...\") literals are rejected by this parser.","triggerScenarios":"Using a char literal like `label: 'x'` or a byte-string literal as an RSX attribute value or text child on a path where the HotLiteral parser must round-trip the value for hot-reload serialization.","commonSituations":"Typing 'x' instead of \"x\" for single-character text; porting keyboard/char values into templates; versions of dioxus tightening which literals hot-reload supports.","solutions":["Replace the char/byte-string literal with a String, e.g. bind `let ch = String::from('x');` and use the variable","Compute the value outside rsx and pass the variable as the attribute value","If the literal must stay, do a full rebuild instead of relying on hot-reload for that template"],"exampleFix":"// before\nrsx! { button { onclick: move |_| {}, '{x}' } }\n\n// after\nlet label = String::from(x);\nrsx! { button { onclick: move |_| {}, \"{label}\" } }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use string literals (\"x\") rather than char ('x') or byte-string literals inside rsx","Bind non-supported literal types to variables outside the rsx! block","After upgrading dioxus, cargo check templates that rely on hot-reload literal round-tripping"],"tags":["rsx","hot-reload","literal","compile-time"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}