Closed lacygoill closed 2 years ago
There is no obvious right choice. If we follow recent changes, then type checking for map() should be strict for declared types (a variable must not change type) and permissive for constant values. The result of range() is not a constant, it's not declared either. Giving an error here does not appear useful, thus I tend to go for the permissive way.
Steps to reproduce
Run this shell command:
This is echo'ed:
Run this other shell command:
An error is given:
Expected behavior
Not sure, but the current situation is inconsistent. Either the second shell command should not give any error. Or the first one should give a type mismatch error, like the second one.
I would prefer no error in both commands; but I suspect that – the way type checking is intended to work – an error should always be given. Because internally, the return type of
range()
is probablylist<number>
, that type is attached to the output (hererange(3)
), andmap()
cannot change the type of a value whose type is declared. Although, here, we did not declarelist<number>
anywhere (but Vim did it internally).Version of Vim
8.2 Included patches: 1-4264
Environment
Operating system: Ubuntu 20.04.3 LTS Terminal: xterm Value of $TERM: xterm-256color Shell: zsh 5.8