diem/diem · error

ICE expansion failed

Error message

ICE expansion failed

What it means

This ICE panic in `add_drop_ability_tip` (language/move-lang/src/cfgir/locals/mod.rs:369) fires when computing abilities for a type argument and the type is still `T::Var(_)` or `T::Apply(None, _, _)` — i.e. the type-expansion pass has not run or failed. The compiler expects every type reaching CFGIR analysis to be fully expanded with concrete abilities. It indicates a broken internal invariant, typically a compiler bug.

Source

Thrown at language/move-lang/src/cfgir/locals/mod.rs:369

            t
        ),
    };
    crate::typing::core::ability_not_satisified_tips(
        &crate::typing::core::Subst::empty(),
        diag,
        Ability_::Drop,
        &ty,
        declared_loc_opt,
        declared_abilities,
        ty_args.iter().map(|ty_arg| {
            let abilities = match &ty_arg.value {
                T::Unit => AbilitySet::collection(ty_arg.loc),
                T::Ref(_, _) => AbilitySet::references(ty_arg.loc),
                T::UnresolvedError | T::Anything => AbilitySet::all(ty_arg.loc),
                T::Param(TParam { abilities, .. }) | T::Apply(Some(abilities), _, _) => {
                    abilities.clone()
                }
                T::Var(_) | T::Apply(None, _, _) => panic!("ICE expansion failed"),
            };
            (ty_arg, abilities)
        }),
    )
}

fn single_type_to_naming_type(sp!(loc, st_): SingleType) -> N::Type {
    sp(loc, single_type_to_naming_type_(st_))
}

fn single_type_to_naming_type_(st_: SingleType_) -> N::Type_ {
    use SingleType_ as S;
    use N::Type_ as T;
    match st_ {
        S::Ref(mut_, b) => T::Ref(mut_, Box::new(base_type_to_naming_type(b))),
        S::Base(sp!(_, b_)) => base_type_to_naming_type_(b_),
    }
}

View on GitHub (pinned to fc4714a8ea)

Solutions

  1. Fix the unresolved type references in the Move source so expansion succeeds (check imports and type names) before the analysis runs.
  2. Minimize the failing program and report the ICE to the Move compiler maintainers.
  3. Retry with a different/newer compiler version where the expansion bug may be fixed.

Example fix

// before (type that fails to expand)
let x: UnknownType = ...;

// after (fully resolvable type)
use 0x1::vector;
let x: vector<u8> = vector::empty();
Defensive patterns

Strategy: validation

Validate before calling

// ensure all imports/types resolve before compilation
// (check compiler diagnostics after parsing/expansion pass)
if diagnostics_after_expansion(env) { return Err("unresolved types"); }

Try / catch

std::panic::catch_unwind(|| run_cfgir_locals(ast))
    .map_err(|_| "compiler ICE: unexpanded type")?;

Prevention

When it happens

Trigger: Type expansion did not resolve a type variable or left an unexpanded `T::Apply(None, ...)` node, and locals analysis then inspects that type argument while constructing a drop-ability tip from a `command` or `lvalue`.

Common situations: Compiling code containing types the expansion pass could not resolve (unresolved module/type names that were not surfaced as errors earlier); compiler bugs/regressions; stale intermediate artifacts from a mismatched compiler version.

Related errors


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