Fix list[0].i = 5 when list[0] returns a pointer. #2888

This commit is contained in:
Christoffer Lerno
2026-02-05 00:34:17 +01:00
parent 5e656603a5
commit dcf695c726
5 changed files with 37 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
struct Node
{
int i;
}
struct MyList
{
Node** entries;
}
fn Node* MyList.get(&self, usz index) @operator([]) => self.entries[index];
fn Node** MyList.get_ref(&self, usz index) @operator(&[]) => &self.entries[index];
fn int main()
{
Node n;
Node* np = &n;
MyList list = {.entries = &np};
list[0].i = 5;
return 0;
}