Commit Graph

6 Commits

Author SHA1 Message Date
aa13482191 Core: Write struct fields through a map-lookup pointer, null-checked
`s = m.lookup(k); s.count = 5` (and `s.count += 1`) compiled without an
error to IR llc rejects: "invalid getelementptr indices" on
`getelementptr inbounds i64*, i64** %s, i32 0, i32 0`. Both the
assignment and augmented-assignment paths indexed into the local's own
slot, which for a lookup or cast local holds a pointer to the struct, not
the struct. Reads already got this right in access_struct_field.

with_struct_field_ptr now resolves a field for a write the same way:
directly for a struct local; for a pointer local, by loading the pointer,
casting it to the struct type, and emitting the store only on the
non-null path (emit_if_not_null, the write-side counterpart of
_null_checked_operation). The write lands in the map entry itself, so
`s.count += 1` is an in-place update with no update() call, and the
maps/structs guide examples that did update(k, s) after a field
assignment now just assign.
2026-09-25 11:22:21 +05:30
0482aa2be9 Fix deref_to_depth loop type check to use cur_type
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-31 15:31:43 +05:30
8ad5fb8a3a Janitorial: Remove useless comments 2025-11-23 06:29:44 +05:30
cbe365d760 Unify struct and pointer to struct handling, abstract null check in ir_ops 2025-11-23 06:26:09 +05:30
9def969592 Make map val struct type allocation work by fixing pointer deref and debuginfogen: WIP 2025-11-22 13:20:09 +05:30
45e6ce5e5c Move deref_to_depth to expr/ir_ops.py 2025-10-13 04:01:27 +05:30