Error message in Vim 9 script

26 views
Skip to first unread message

Salman Halim

unread,
Jun 4, 2021, 2:05:18 PM6/4/21
to Vim Users
Hello,

I'm getting this error in my Vim 9 script in Windows GVim 8.2.2912:

Error detected while compiling C:/vim/Vimfiles/plugin/Test.vim[17]..function TestBrokenCall:
line    8:
E1013: Argument 3: type mismatch, expected string but got bool

Here is a simple duplication script:

vim9script

export def g:BrokenCall( lineNumber: number, insertMode: bool, templateToUse: string = 'defaultValue' ): void
  echo lineNumber
  echo insertMode
  echo templateToUse
enddef

export def g:TestBrokenCall( line1: number, line2: number, templateName: string ): void
  # This works
  # call BrokenCall( line1, 0 )

  # This results in
  # Error detected while compiling C:/vim/Vimfiles/plugin/Test.vim[17]..function TestBrokenCall:
  # line    8:
  # E1013: Argument 3: type mismatch, expected string but got bool
  call BrokenCall( line1, 0, templateName )
enddef

call TestBrokenCall(3, 5, 'ab')

Calling BrokenCall with just two arguments works, but passing in the third argument doesn't. The third argument can be a hard-coded string or the variable. Similarly, having BrokenCall contain a default value for the third parameter doesn't seem to matter, either.

Thank you,

Salman

--
 
Salman

I, too, shall something make and glory in the making.

Bram Moolenaar

unread,
Jun 4, 2021, 2:47:32 PM6/4/21
to vim...@googlegroups.com, Salman Halim
I can reproduce it. The "export" and "g:" are not needed.
The problem is that converting the number zero to a bool is done at the
wrong stack offset. I'll make a patch.

--
Living on Earth includes an annual free trip around the Sun.

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