lang: for-loop over List(T); deref a *T method receiver

The collection for-loop now iterates a List(T)-like struct ({ items: [*]T, len, … }) — and a *List — by viewing it as items[0..len]. So 'for legal: (m)' / 'for pieces: (*p)' work like iterating a slice, with by-ref captures writing back into the backing.

fixupMethodReceiver also derefs a *T receiver when the method takes T by value, so a 'for xs: (*x)' capture can call value-self methods (x.method()). Regression: examples/for-list.sx.
This commit is contained in:
agra
2026-05-31 11:13:57 +03:00
parent 6b5edc77b4
commit 5c9d8c23ca
4 changed files with 102 additions and 5 deletions

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1,4 @@
sum 60
sum2 360
via ptr 360
boxes 7