{"record":{"id":"29b367aa580fe109","repo":"diem/diem","slug":"type-is-not-allowed-in-scripts","errorCode":null,"errorMessage":"Type {:?} is not allowed in scripts.","messagePattern":"Type (.+?) is not allowed in scripts\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"language/move-prover/abigen/src/abigen.rs","lineNumber":236,"sourceCode":"                Ok(bytes)\n            }\n        }\n    }\n\n    fn get_type_tag(&self, ty0: &ty::Type) -> anyhow::Result<TypeTag> {\n        use ty::Type::*;\n        let tag = match ty0 {\n            Primitive(prim) => {\n                use ty::PrimitiveType::*;\n                match prim {\n                    Bool => TypeTag::Bool,\n                    U8 => TypeTag::U8,\n                    U64 => TypeTag::U64,\n                    U128 => TypeTag::U128,\n                    Address => TypeTag::Address,\n                    Signer => TypeTag::Signer,\n                    Num | Range | EventStore => {\n                        bail!(\"Type {:?} is not allowed in scripts.\", ty0)\n                    }\n                }\n            }\n            Vector(ty) => {\n                let tag = self.get_type_tag(ty)?;\n                TypeTag::Vector(Box::new(tag))\n            }\n            Tuple(_)\n            | Struct(_, _, _)\n            | TypeParameter(_)\n            | Fun(_, _)\n            | TypeDomain(_)\n            | ResourceDomain(..)\n            | Error\n            | Var(_)\n            | Reference(_, _) => bail!(\"Type {:?} is not allowed in scripts.\", ty0),\n        };\n        Ok(tag)","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/diem/diem/blob/fc4714a8ea273b6efe8b13dbce72ea60aad9a16c/language/move-prover/abigen/src/abigen.rs#L218-L254","documentation":"get_type_tag converts Move prover types into TypeTags for script ABI generation. Move's builtin domain types Num, Range, and EventStore only exist inside the prover/spec language and have no runtime representation in scripts, so encountering one is an unrecoverable mapping failure. The library bails with this message naming the offending type.","triggerScenarios":"generate_abi_for_function encountering a function parameter or return type that is (or contains) the spec-only builtin Num, Range, or EventStore type; get_type_tag recursing into a Vector element of those types.","commonSituations":"Running abigen on a module whose public functions use specification-only types (e.g. a `range` or `num` builtin from the Move spec language) as if they were runtime values; accidentally exposing spec internals through script-visible signatures.","solutions":["Remove spec-only builtin types (Num, Range, EventStore) from the function's runtime signature","Replace them with concrete runtime types such as u64/u128 for numeric spec types","Move spec-only logic into `spec` blocks or `intrinsic`-annotated helpers not part of the script ABI","Re-run abigen after cleaning the signature"],"exampleFix":"// before\npublic fun f(x: num): range { ... }\n// after\npublic fun f(x: u64): u64 { ... }","handlingStrategy":"validation","validationCode":"fn is_script_safe(ty: &Type) -> bool {\n    use Type::*;\n    !matches!(ty, Num | Range | EventStore)\n}\n// check every param/return before generate_abi_for_function","typeGuard":"fn is_runtime_builtin(ty: &Type) -> bool {\n    matches!(ty, Type::U8 | Type::U64 | Type::U128 | Type::Address | Type::Signer)\n}","tryCatchPattern":"match abigen::get_type_tag(&ty) {\n    Ok(tag) => tag,\n    Err(e) if e.to_string().contains(\"not allowed in scripts\") => {\n        eprintln!(\"function uses spec-only types; skipping ABI generation\");\n        return None;\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep spec-only builtins (Num, Range, EventStore) inside spec blocks, never in runtime signatures","Use u64/u128 for numeric spec reasoning instead of `num` in public functions","Review public function signatures before running abigen","Filter internal/spec functions out of the ABI generation input"],"tags":["move-prover","abi","type-system","scripts"],"backgroundTag":"unsupported-type-in-abi","analyzedSha":"fc4714a8ea273b6efe8b13dbce72ea60aad9a16c","analyzedAt":"2026-09-04T21:07:05.890Z","contentChangedAt":"2026-09-04T21:07:05.890Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}