Function argument type check doesn't work properly for a class

6 views
Skip to first unread message

Yegappan Lakshmanan

unread,
Jan 7, 2023, 12:58:27 PM1/7/23
to vim_dev
Hi,

When a function accepts an argument of class type, the argument
type check is not working properly. Example:

---------------------------------------------------
vim9script

class One
endclass

class Two
endclass

def Show(a: One)
echomsg a->string()
enddef

var b = Two.new()
Show(b)
------------------------------------------------------

In this example, the function Show() accepts an argument of type "One".
But when the function is called with an argument of type "Two", there is
no error.

Regards,
Yegappan

Bram Moolenaar

unread,
Jan 7, 2023, 2:02:52 PM1/7/23
to vim...@googlegroups.com, Yegappan Lakshmanan
This isn't implemented yet. Currently it only checks that it is a class
type, it should also check that it is the same class. Or, in the case
of an interface, a class that implements the interface. I should get to
this one of the coming days.

--
ARTHUR: Be quiet! I order you to shut up.
OLD WOMAN: Order, eh -- who does he think he is?
ARTHUR: I am your king!
OLD WOMAN: Well, I didn't vote for you.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages