Vim9: tuple slice has the type of the whole tuple in a compiled function

Offen
#21,649 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 13 Tagen

Dieses Issue hat noch niemand übernommen.

  • #21650 von @yegappan — ohne Merge geschlossen

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
vim
Bereich
backend

Rechercherichtung

Compare how tuple slicing is type-checked at script level and in compiled Vim9 functions, using the examples in the issue as reproductions. Start by locating the tuple slice type-checking and compiled-function paths; the issue names no files or tests. Done means both contexts agree: the first example succeeds in a function and the second reports the expected E1012 type mismatch.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug Vim9 script
Steps to reproduce

Sourcing the following script:

vim9script
def F()
  var s: tuple<string> = (1, 'a')[1 :]
enddef
F()

gives E1012: Type mismatch; expected tuple<string> but got tuple<number, string>, while the same line at script level works:

vim9script
var s: tuple<string> = (1, 'a')[1 :]
echo s

The reverse is accepted:

vim9script
def G()
  var t: tuple<number, string> = (1, 'a')
  var s: tuple<number, string> = t[1 :]
  echo typename(s) s
enddef
G()

prints tuple<number, string> ('a', ), while at script level it fails with E1012:

vim9script
var t: tuple<number, string> = (1, 'a')
var s: tuple<number, string> = t[1 :]
echo typename(s) s 
Expected behaviour

The same as at script level: the first example works, the second one gives E1012: Type mismatch; expected tuple<number, string> but got tuple<string>.

Version of Vim

9.2.1202

Environment

Linux (Ubuntu)

Vorherrschende Sprache
Vim Script
Sterne
41.4k
Forks
6.2k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus vim/vim

Alle Issues in vim/vim

Ähnliche Issues

Weitere Issues zu Backend & API Design

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.