[vim/vim] [vim9script] "Too many arguments for function" when class has some (but not all) overriden methods (Issue #12524)

111 views
Skip to first unread message

Lifepillar

unread,
Jun 11, 2023, 3:03:16 PM6/11/23
to vim/vim, Subscribed

Steps to reproduce

Source this script:

vim9script

class Widget
  this._lnum: number = 1

  def SetY(lnum: number)
    this._lnum = lnum
  enddef

  def Text(): string
    return ''
  enddef
endclass

class Foo extends Widget
  # def SetY(lnum: number)
  #   this._lnum = lnum
  # enddef

  def Text(): string
    return '<Foo>'
  enddef
endclass


def Stack(w1: Widget, w2: Widget): list<Widget>
  w1.SetY(1)
  w2.SetY(2)
  return [w1, w2]
enddef

var foo1 = Foo.new()
var foo2 = Foo.new()
echo Stack(foo1, foo2)

This results in E118: Too many arguments for function: Text. A workaround consists in overriding the other method (uncomment the commented code). The code executes without errors also when the Text() method is removed from the subclass (but that is not a practical workaround).

Expected behaviour

The code snippet above should compile and run without errors.

Version of Vim

9.0.1626

Environment

macOS 13.4
Apple Terminal
xterm-256color
ZSH 5.9

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12524@github.com>

Christian Brabandt

unread,
Aug 16, 2023, 2:21:00 PM8/16/23
to vim/vim, Subscribed

Closed #12524 as completed via a456b12.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/12524/issue_event/10111490765@github.com>

Reply all
Reply to author
Forward
0 new messages