mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix list[0].i = 5 when list[0] returns a pointer. #2888
This commit is contained in:
19
test/test_suite/overloading/operator_pointer.c3t
Normal file
19
test/test_suite/overloading/operator_pointer.c3t
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user