fixing infinite recusrion bug

This commit is contained in:
Jakub Doka 2024-10-01 14:00:41 +02:00
parent 2a4d27d8e6
commit 1ee8d464c6
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
2 changed files with 17 additions and 2 deletions

View file

@ -759,9 +759,16 @@ impl Codegen {
use {Expr as E, TokenKind as T}; use {Expr as E, TokenKind as T};
let value = match *expr { let value = match *expr {
E::Mod { id, .. } => Some(Value::ty(ty::Kind::Module(id).compress())), E::Mod { id, .. } => Some(Value::ty(ty::Kind::Module(id).compress())),
E::Struct { captured, .. } => { E::Struct { captured, packed, fields, .. } => {
if captured.is_empty() { 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 { } else {
let values = captured let values = captured
.iter() .iter()

View file

@ -705,6 +705,14 @@ impl Types {
} }
ty 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, .. } => { Expr::Struct { pos, fields, packed, .. } => {
let sym = SymKey { file, ident: pos }; let sym = SymKey { file, ident: pos };
if let Some(&ty) = self.syms.get(&sym) { if let Some(&ty) = self.syms.get(&sym) {