1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: add error for .map() calling a fn with multiple return values (prevent inaccessible tuple leak)

This commit is contained in:
Delyan Angelov
2022-01-04 23:10:58 +02:00
parent 6c1ae4f689
commit b3930c3d6a
4 changed files with 22 additions and 3 deletions

View File

@ -1064,10 +1064,10 @@ the `it` built-in variable to achieve a classic `map/filter` functional paradigm
```v
// using filter, map and negatives array slices
a := ['pippo.jpg', '01.bmp', '_v.txt', 'img_02.jpg', 'img_01.JPG']
res := a.filter(it#[-4..].to_lower() == '.jpg').map(fn (w string) (string, int) {
return w.to_upper(), w.len
res := a.filter(it#[-4..].to_lower() == '.jpg').map(fn (w string) string {
return w.to_upper()
})
// [('PIPPO.JPG', 9), ('IMG_02.JPG', 10), ('IMG_01.JPG', 10)]
// ['PIPPO.JPG', 'IMG_02.JPG', 'IMG_01.JPG']
```
### Fixed size arrays