Commit cbd9c57
committed
v3: keep pointer-bearing generic args from parsing as fixed-array lengths (fix #28884)
`is_fixed_array_len_text` treated every non-leading `&` as a bitwise-and
length operator, so `Foo[fn (&Baz) int]` (and `Foo[[]&T]`, `Foo[?&T]`,
`Foo[&&T]`, `Foo[Box[&T]]`, ...) was parsed as a fixed array of `Foo`
with length `fn (&Baz) int`. Field access then failed with
"`[fn (&Baz) int]foo.Foo` has no property `value`", and fn-field calls
became "unknown function".
Reject argument text that starts with type-only syntax (`&`, `?`, `!`,
`[`, `...`, `map[`, `fn`, `chan`, `thread`, `shared`, `atomic`, `mut`)
and ignore `&`/`-` nested in brackets. The transform and cgen typeof
helpers get the same `&`/`?`/`!` prefix check so `?&T` and `&&T`
instances are not mangled as fixed arrays later on.1 parent b595356 commit cbd9c57
6 files changed
Lines changed: 128 additions & 7 deletions
File tree
- vlib/v
- gen/c
- tests/generic_fn_ptr_arg_28884
- generics28884
- transform
- types
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17206 | 17206 | | |
17207 | 17207 | | |
17208 | 17208 | | |
17209 | | - | |
| 17209 | + | |
17210 | 17210 | | |
17211 | 17211 | | |
17212 | 17212 | | |
| |||
Lines changed: 89 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
Whitespace-only changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22219 | 22219 | | |
22220 | 22220 | | |
22221 | 22221 | | |
22222 | | - | |
22223 | | - | |
22224 | | - | |
| 22222 | + | |
| 22223 | + | |
| 22224 | + | |
22225 | 22225 | | |
22226 | 22226 | | |
22227 | 22227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14398 | 14398 | | |
14399 | 14399 | | |
14400 | 14400 | | |
| 14401 | + | |
| 14402 | + | |
| 14403 | + | |
| 14404 | + | |
| 14405 | + | |
| 14406 | + | |
| 14407 | + | |
| 14408 | + | |
| 14409 | + | |
| 14410 | + | |
14401 | 14411 | | |
14402 | 14412 | | |
| 14413 | + | |
| 14414 | + | |
| 14415 | + | |
| 14416 | + | |
| 14417 | + | |
14403 | 14418 | | |
14404 | 14419 | | |
14405 | 14420 | | |
14406 | | - | |
14407 | | - | |
14408 | | - | |
| 14421 | + | |
| 14422 | + | |
| 14423 | + | |
| 14424 | + | |
14409 | 14425 | | |
14410 | 14426 | | |
14411 | 14427 | | |
| |||
0 commit comments