From b516302ac0d15f17289f85ad6adc1237cd60ecaa Mon Sep 17 00:00:00 2001 From: Jake Fecher Date: Tue, 21 Jan 2025 11:32:15 -0600 Subject: [PATCH] Return empty fields by default --- compiler/noirc_frontend/src/hir_def/types.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/noirc_frontend/src/hir_def/types.rs b/compiler/noirc_frontend/src/hir_def/types.rs index e9c561965f2..21b0d59d8f2 100644 --- a/compiler/noirc_frontend/src/hir_def/types.rs +++ b/compiler/noirc_frontend/src/hir_def/types.rs @@ -456,6 +456,10 @@ impl DataType { fn fields_raw(&self) -> &[StructField] { match &self.body { TypeBody::Struct(fields) => fields, + // Turns out we call `fields_raw` in a few places before a type may be fully finished. + // One of these is when checking for nested slices, so that check will have false + // negatives. + TypeBody::None => &[], _ => panic!("Called DataType::fields_raw on a non-struct type: {}", self.name), } }