From 1ee8d464c625a28163604588ea3ee9e9e6be5230 Mon Sep 17 00:00:00 2001 From: Jakub Doka Date: Tue, 1 Oct 2024 14:00:41 +0200 Subject: [PATCH] fixing infinite recusrion bug --- hblang/src/codegen.rs | 11 +++++++++-- hblang/src/lib.rs | 8 ++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/hblang/src/codegen.rs b/hblang/src/codegen.rs index a5583fb..47aa551 100644 --- a/hblang/src/codegen.rs +++ b/hblang/src/codegen.rs @@ -759,9 +759,16 @@ impl Codegen { use {Expr as E, TokenKind as T}; let value = match *expr { E::Mod { id, .. } => Some(Value::ty(ty::Kind::Module(id).compress())), - E::Struct { captured, .. } => { + E::Struct { captured, packed, fields, .. } => { if captured.is_empty() { - Some(Value::ty(self.ty(expr))) + Some(Value::ty( + ty::Kind::Struct(self.build_struct( + self.ci.file, + packed.then_some(1), + fields, + )) + .compress(), + )) } else { let values = captured .iter() diff --git a/hblang/src/lib.rs b/hblang/src/lib.rs index bbd3314..638d803 100644 --- a/hblang/src/lib.rs +++ b/hblang/src/lib.rs @@ -705,6 +705,14 @@ impl Types { } ty } + Expr::Slice { size: None, item, .. } => { + let ty = self.ty(file, item, files)?; + self.make_array(ty, ArrayLen::MAX) + } + //Expr::Slice { size: Some(&Expr::Number { value, .. }), item, .. } => { + // let ty = self.ty(file, item, files)?; + // self.make_array(ty, value as _) + //} Expr::Struct { pos, fields, packed, .. } => { let sym = SymKey { file, ident: pos }; if let Some(&ty) = self.syms.get(&sym) {