diff options
| author | Baitinq <[email protected]> | 2025-05-10 20:26:09 +0200 |
|---|---|---|
| committer | Baitinq <[email protected]> | 2025-05-10 20:26:09 +0200 |
| commit | ae57ab4ce8da74e9357122562efee175f1e4c664 (patch) | |
| tree | 65812e8496b50129ace50f015917a8038319ccde | |
| parent | Codegen: Support declaring functions multiple times (diff) | |
| download | pry-lang-ae57ab4ce8da74e9357122562efee175f1e4c664.tar.gz pry-lang-ae57ab4ce8da74e9357122562efee175f1e4c664.tar.bz2 pry-lang-ae57ab4ce8da74e9357122562efee175f1e4c664.zip | |
Codegen: Fix: Don't change underlying type if dereference
| -rw-r--r-- | src/codegen.zig | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/codegen.zig b/src/codegen.zig index bcac597..a9597c4 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -151,8 +151,10 @@ pub const CodeGen = struct { ptr = self.environment.get_variable(identifier.name).?.value; } + var typ = variable.node_type; if (assignment_statement.is_dereference) { - ptr = llvm.LLVMBuildLoad2(self.builder, try self.get_llvm_type(variable.node_type), ptr, ""); + typ = self.environment.get_variable(identifier.name).?.node_type; + ptr = llvm.LLVMBuildLoad2(self.builder, try self.get_llvm_type(typ), ptr, ""); } _ = llvm.LLVMBuildStore(self.builder, variable.value, ptr); @@ -164,7 +166,7 @@ pub const CodeGen = struct { const new_variable = try self.create_variable(.{ .value = ptr, .node = variable.node, - .node_type = variable.node_type, + .node_type = typ, .stack_level = null, }); // Adding variable doesnt actually replace the variable of previous scope |