diff --git a/src/transform/binding_remapper.cc b/src/transform/binding_remapper.cc index ce6a8121ed..67d47cd030 100644 --- a/src/transform/binding_remapper.cc +++ b/src/transform/binding_remapper.cc @@ -113,7 +113,15 @@ void BindingRemapper::Run(CloneContext& ctx, const DataMap& inputs, DataMap&) { auto ac_it = remappings->access_controls.find(from); if (ac_it != remappings->access_controls.end()) { ast::Access ac = ac_it->second; - auto* ty = ctx.src->Sem().Get(var)->Type()->UnwrapRef(); + auto* sem = ctx.src->Sem().Get(var); + if (sem->StorageClass() != ast::StorageClass::kStorage) { + ctx.dst->Diagnostics().add_error( + diag::System::Transform, + "cannot apply access control to variable with storage class " + + std::string(ast::str(sem->StorageClass()))); + return; + } + auto* ty = sem->Type()->UnwrapRef(); ast::Type* inner_ty = CreateASTTypeFor(ctx, ty); auto* new_var = ctx.dst->create( ctx.Clone(var->source()), ctx.Clone(var->symbol()),