[vim9script] Default value for object argument?

8 views
Skip to first unread message

Lifepillar

unread,
Mar 12, 2023, 7:27:24 AM3/12/23
to vim...@googlegroups.com
How do you define a default value for a function argument whose type is
a class? I have tried this:

vim9script

class X
endclass

def F(x: X = null_object)
enddef

F()

But this results in:

E1013: Argument 1: type mismatch, expected object<X> but got object<Unknown>

Maybe this is not supported yet?

Thanks,
Life.



Bram Moolenaar

unread,
Mar 12, 2023, 4:17:36 PM3/12/23
to vim...@googlegroups.com, Lifepillar
The type system isn't fully worked out yet. This works, but it's not
ideal:

var def: X
def F(x: X = def)
enddef

I'm not sure what syntax we should use for "null object of class X"?

--
Two fish in a tank. One says to the other:
"Do you know how to drive this thing?"

/// 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