Fix using custom type-labels for e.g. return type

This commit is contained in:
Sofia 2025-07-17 20:20:07 +03:00
parent 0f782dcb96
commit ce2278ce45
3 changed files with 12 additions and 7 deletions

View File

@ -39,7 +39,7 @@ impl Parse for Type {
"u64" => TypeKind::U64,
"u128" => TypeKind::U128,
"string" => TypeKind::String,
_ => Err(stream.expected_err("known type identifier")?)?,
_ => TypeKind::Custom(ident),
}
} else {
return Err(stream.expected_err("type identifier")?)?;

View File

@ -275,7 +275,7 @@ impl From<ast::TypeKind> for mir::TypeKind {
mir::TypeKind::Array(Box::new(mir::TypeKind::from(*type_kind.clone())), *length)
}
ast::TypeKind::String => mir::TypeKind::StringPtr,
ast::TypeKind::Custom(_) => todo!("Add processing for custom types"),
ast::TypeKind::Custom(name) => mir::TypeKind::CustomType(name.clone()),
}
}
}

View File

@ -5,19 +5,24 @@ struct Test {
second: [u32; 4]
}
fn main() -> v u32 {
let mut value = [Test {
fn test() -> [Test; 1] {
let value = [Test {
field: 5,
second: [6, 3, "hello", 8],
second: [6, 3, 4, 8],
}];
return value;
}
fn main() -> u32 {
let mut value = test();
let val1 = 0;
let val2 = 1;
// value[val1].second[val2 + 1] = 99;
let mut b = valude[val1];
let mut b = value[val1];
b.second[2] = 99;
return value[val1].sezcond[2];
return value[val1].second[2];
}