Fix somelist_pointer

This commit is contained in:
Sofia 2026-04-16 21:55:43 +03:00
parent c3e12b087a
commit 668e18e8ba
2 changed files with 3 additions and 2 deletions

View File

@ -256,8 +256,7 @@ namespace AST {
codegen::StackValue IndexAccessExpression::codegen(codegen::Builder& builder, codegen::Scope& scope) { codegen::StackValue IndexAccessExpression::codegen(codegen::Builder& builder, codegen::Scope& scope) {
auto lvalue_scope = scope.with_lvalue(); auto value = this->m_expr->codegen(builder, scope);
auto value = this->m_expr->codegen(builder, lvalue_scope);
std::shared_ptr<types::Type> inner_ty{}; std::shared_ptr<types::Type> inner_ty{};
std::vector<llvm::Value*> idx_list{ }; std::vector<llvm::Value*> idx_list{ };

2
test.c
View File

@ -29,10 +29,12 @@ int main() {
printf(text, fibonacci(10)); printf(text, fibonacci(10));
char somelist[5] = { 1, 2, 3, 4, 5 }; char somelist[5] = { 1, 2, 3, 4, 5 };
char* somelist_ptr = somelist;
change_first(somelist); change_first(somelist);
printf("first element: %d!\n", somelist[0]); printf("first element: %d!\n", somelist[0]);
printf("first element via ptr: %d!\n", somelist_ptr[0]);
struct Otus otus = { 5 }; struct Otus otus = { 5 };
update(otus); update(otus);