diem/diem · error

Unsupported inhabitation. Type: {:#?}

Error message

Unsupported inhabitation. Type: {:#?}

What it means

inhabit_with_bytecode_seq only knows how to inhabit a fixed set of SignatureToken kinds (primitives, structs, references, etc.). Any other token reaching the catch-all arm triggers unimplemented! with the token dumped, meaning the type oracle handed the generator a type it has no inhabitation strategy for.

Source

Thrown at language/testing-infra/test-generation/src/bytecode_generator.rs:937

                    .iter()
                    .flat_map(|field| {
                        let field_sig_tok = &field.signature.0;
                        let reified_field_sig_tok = substitute(field_sig_tok, instantiation);
                        Self::inhabit_with_bytecode_seq(module, &reified_field_sig_tok)
                    })
                    .collect();
                let instantiation_index = module.add_instantiation(instantiation.clone());
                let struct_inst = StructDefInstantiation {
                    def: StructDefinitionIndex(struct_def_idx as TableIndex),
                    type_parameters: instantiation_index,
                };
                let si_idx = module.add_struct_instantiation(struct_inst);
                bytecodes.push(Bytecode::PackGeneric(StructDefInstantiationIndex(
                    si_idx.0 as TableIndex,
                )));
                bytecodes
            }
            _ => unimplemented!("Unsupported inhabitation. Type: {:#?}", token),
        }
    }
}

View on GitHub (pinned to fc4714a8ea)

Solutions

  1. Add a match arm implementing inhabitation for the reported token kind
  2. Ensure all generic type parameters are instantiated with concrete types before calling inhabitation
  3. Filter unsupported token kinds out of the type oracle's candidate set

Example fix

// before
_ => unimplemented!("Unsupported inhabitation. Type: {:#?}", token),
// after
SignatureToken::TypeVariable(_) => return None, // skip uninstantiated generics
_ => unimplemented!("Unsupported inhabitation. Type: {:#?}", token),
Defensive patterns

Strategy: type-guard

Validate before calling

match token {
    SignatureToken::Bool | SignatureToken::U8 | SignatureToken::U64 | SignatureToken::U128
    | SignatureToken::Address | SignatureToken::Struct(_) | SignatureToken::Vector(_) => ok(),
    _ => skip_unsupported(token),
}

Type guard

fn is_supported_token(t: &SignatureToken) -> bool {
    !matches!(t, SignatureToken::TypeVariable(_) | SignatureToken::Signer | SignatureToken::Reference(_))
}

Prevention

When it happens

Trigger: Calling inhabit_with_bytecode_seq with an unsupported SignatureToken — e.g. TypeVariable/uninstantiated generic parameters, vector of unsupported elements, signer, or a newly added token kind not yet covered by the match.

Common situations: Extending the Move language or the test generator with a new SignatureToken variant; running the generator on modules whose signatures contain type parameters that were never instantiated.

Related errors


AI-assisted analysis of diem/diem@fc4714a8ea (2026-09-04). Data as JSON: /api/errors/0e9b41b1e3999bf4. Report an issue: GitHub.