Commit f896627
patch 9.2.0265: unnecessary restrictions for defining dictionary function names
Problem: unnecessary restrictions for defining dictionary function
names
Solution: Allow defining dict function with bracket key that is not a
valid identifier (thinca)
In Vim script, "function obj.func()" and "function obj['func']()" both
define a dictionary function. However, the bracket form required the
key to match function naming rules (eval_isnamec), so
"function obj['foo-bar']()" failed with E475.
Assigning and calling already work: "let obj['foo-bar'] = obj.func"
and "call obj['foo-bar']()" are valid. Only the definition was
incorrectly restricted.
Skip the identifier check when the name comes from fd_newkey (i.e. the
key was given in bracket notation). Dictionary keys may be any string.
Supported by AI
closes: #19833
Signed-off-by: thinca <[email protected]>
Signed-off-by: Yegappan Lakshmanan <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>1 parent d13f135 commit f896627
3 files changed
Lines changed: 45 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
584 | 584 | | |
585 | 585 | | |
586 | 586 | | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
587 | 599 | | |
588 | 600 | | |
589 | 601 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5253 | 5253 | | |
5254 | 5254 | | |
5255 | 5255 | | |
5256 | | - | |
| 5256 | + | |
| 5257 | + | |
| 5258 | + | |
| 5259 | + | |
| 5260 | + | |
5257 | 5261 | | |
5258 | | - | |
5259 | | - | |
5260 | | - | |
5261 | | - | |
5262 | | - | |
5263 | | - | |
5264 | | - | |
5265 | | - | |
5266 | | - | |
5267 | | - | |
5268 | | - | |
5269 | | - | |
5270 | | - | |
5271 | | - | |
5272 | | - | |
| 5262 | + | |
| 5263 | + | |
| 5264 | + | |
| 5265 | + | |
| 5266 | + | |
| 5267 | + | |
| 5268 | + | |
| 5269 | + | |
| 5270 | + | |
| 5271 | + | |
| 5272 | + | |
| 5273 | + | |
| 5274 | + | |
| 5275 | + | |
| 5276 | + | |
| 5277 | + | |
| 5278 | + | |
5273 | 5279 | | |
5274 | | - | |
5275 | | - | |
5276 | | - | |
5277 | | - | |
5278 | | - | |
| 5280 | + | |
| 5281 | + | |
| 5282 | + | |
| 5283 | + | |
| 5284 | + | |
5279 | 5285 | | |
5280 | | - | |
5281 | | - | |
5282 | | - | |
| 5286 | + | |
| 5287 | + | |
| 5288 | + | |
| 5289 | + | |
5283 | 5290 | | |
5284 | 5291 | | |
5285 | 5292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
734 | 734 | | |
735 | 735 | | |
736 | 736 | | |
| 737 | + | |
| 738 | + | |
737 | 739 | | |
738 | 740 | | |
739 | 741 | | |
| |||
0 commit comments