Compare commits

..

13 Commits

Author SHA1 Message Date
Ernie Rael
f8da324619 patch 9.0.2012: Vim9: error message can be more accurate
Problem:  Vim9: error message can be more accurate
Solution: Fix the error messages

Fix message for some single use error messages.

closes: #13312

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
2023-10-11 21:22:12 +02:00
Martin Tournoij
4a82bdfaa8 patch 9.0.2011: INI files not detected
Problem:  INI files not detected
Solution: detect uppercase .INI as dosini files

It previo~1 only worked for lower-case .ini files, but upperc~1 .INI is
also somewhat common on account of DOS' old 8.3 upperc~2 only filena~1.

closes: #13316

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Martin Tournoij <martin@arp242.net>
2023-10-11 21:20:06 +02:00
Christian Brabandt
41e6f7d6ba patch 9.0.2010: [security] use-after-free from buf_contents_changed()
Problem:  [security] use-after-free from buf_contents_changed()
Solution: block autocommands

Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-10-11 21:09:53 +02:00
Yee Cheng Chin
54844857fd patch 9.0.2009: cmdline-completion for comma-separated options wrong
Problem:  cmdline-completion for comma-separated options wrong
Solution: Fix command-line expansions for options with filenames with
          commas

Fix command-line expansions for options with filenames with commas

Cmdline expansion for option values that take a comma-separated list
of file names is currently not handling file names with commas as the
commas are not escaped. For such options, the commas in file names need
to be escaped (to differentiate from a comma that delimit the list
items). The escaped comma is unescaped in `copy_option_part()` during
option parsing.

Fix as follows:
- Cmdline completion for option values with comma-separated file/folder
  names will not start a new match when seeing `\\,` and will instead
  consider it as one value.
- File/folder regex matching will strip the `\\` when seeing `\\,` to
  make sure it can match the correct files/folders.
- The expanded value will escape `,` with `\\,`, similar to how spaces
  are escaped to make sure the option value is correct on the cmdline.

This fix also takes into account the fact that Win32 Vim handles file
name escaping differently. Typing '\,' for a file name results in it
being handled literally but in other platforms '\,' is interpreted as a
simple ',' and commas need to be escaped using '\\,' instead.

Also, make sure this new logic only applies to comma-separated options
like 'path'. Non-list options like 'set makeprg=<Tab>' and regular ex
commands like `:edit <Tab>` do not require escaping and will continue to
work.

Also fix up documentation to be clearer. The original docs are slightly
misleading in how it discusses triple slashes for 'tags'.

closes: #13303
related: #13301

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-10-09 18:12:31 +02:00
Dominique Pellé
b07b9dc4da patch 9.0.2008: test: undofile left behind
Problem:  test: undofile left behind
Solution: cleanup undofile

fix: tmp file not deleted when running make test_undo

Temporary file `.Xtestfile.txt.un~` was left running `make test_undo`
and vim was configured with:
```
./configure --with-features=normal --enable-gui=no --enable-terminal
```

closes: #13304

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Dominique Pellé <dominique.pelle@tomtom.com>
2023-10-09 18:09:20 +02:00
Yegappan Lakshmanan
e467189022 patch 9.0.2007: Vim9: covariant parameter types allowed
Problem:  Vim9: covariant parameter types allowed when assigning
          functions
Solution: Enforce invariant type check for arguments and return value
          when assigning a funcref

closes: #13299
closes: #13305

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-10-09 18:01:06 +02:00
Yegappan Lakshmanan
f4ee1cb74b patch 9.0.2006: Vim9: need more tests
Problem:  Vim9: need more tests
Solution: add additional disassembly tests

closes: #13305

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-10-09 17:57:27 +02:00
Christian Brabandt
b56cef0be0 patch 9.0.2005: partially revert patch v9.0.1997
Problem:  partially revert patch v9.0.1997
Solution: add a comment, to make clear it's not used

related: #13288

Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-10-09 17:55:02 +02:00
Christian Brabandt
d4afbdd071 patch 9.0.2004: Missing test file
Problem:  Missing test file
Solution: git-add the file to the repo

closes: #13305

Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-10-09 08:15:00 +02:00
Christian Brabandt
7879bc5c13 patch 9.0.2003: xxd: compilation warning
Problem:  xxd: compilation warning
Solution: initialize variables

Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-10-08 20:38:43 +02:00
Enno
1e33cd72b6 runtime: make command name for &iskeywordprg more unique (#13297)
See https://github.com/vim/vim/pull/13213/commits by @dkearns:
Rename 'keywordprg' user command to ShKeywordPrg as this is just a
leaking implementation detail.

Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-10-08 19:14:07 +02:00
Yegappan Lakshmanan
b852305dbf patch 9.0.2002: Vim9: need cleanup of class related interface code
Problem:  Vim9: need cleanup of class related interface code
Solution: Remove the unused class variable and class method related code
          for interfaces.

Remove unused class variable and class method related code for
interfaces.

Refactor the code.

Optimize the object/class member double lookup in compile_lhs().

Change unused global functions to static functions.

closes: #13302

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-10-08 19:07:39 +02:00
Antonio Giovanni Colombo
75b277d35c translation(it): updated translation of xxd manpage
Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-10-08 19:05:02 +02:00
38 changed files with 769 additions and 352 deletions

View File

@@ -192,10 +192,27 @@ To include white space in a string option value it has to be preceded with a
backslash. To include a backslash you have to use two. Effectively this
means that the number of backslashes in an option value is halved (rounded
down).
In options 'path', 'cdpath', and 'tags', spaces have to be preceded with three
backslashes instead for compatibility with version 3.0 where the options can
be separated by either commas or spaces.
Comma-separated options like 'backupdir' and 'tags' will also require commas
to be escaped with two backslashes, whereas this is not needed for
non-comma-separated ones like 'makeprg'.
When setting options using |:let| and |literal-string|, you need to use one
fewer layer of backslash.
A few examples: >
:set tags=tags\ /usr/tags results in "tags /usr/tags"
:set tags=tags\\,file results in "tags\,file"
:set tags=tags\\\ file results in "tags\ file"
:set makeprg=make\ file results in "make file"
:let &makeprg='make file' (same as above)
:set makeprg=make\\\ file results in "make\ file"
:set tags=tags\ /usr/tags results in "tags" and "/usr/tags"
:set tags=tags\\\ file results in "tags file"
:let &tags='tags\ file' (same as above)
:set makeprg=make,file results in "make,file"
:set makeprg=make\\,file results in "make\,file"
:set tags=tags,file results in "tags" and "file"
:set tags=tags\\,file results in "tags,file"
:let &tags='tags\,file' (same as above)
The "|" character separates a ":set" command from a following command. To
include the "|" in the option value, use "\|" instead. This example sets the
@@ -8213,8 +8230,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|+emacs_tags|: "./tags,./TAGS,tags,TAGS")
global or local to buffer |global-local|
Filenames for the tag command, separated by spaces or commas. To
include a space or comma in a file name, precede it with a backslash
(see |option-backslash| about including spaces and backslashes).
include a space or comma in a file name, precede it with backslashes
(see |option-backslash| about including spaces/commas and backslashes).
When a file name starts with "./", the '.' is replaced with the path
of the current file. But only when the 'd' flag is not included in
'cpoptions'. Environment variables are expanded |:set_env|. Also see

View File

@@ -131,9 +131,11 @@ Ricostruisce: converte (o mette una patch) da immagine esadecimale, a file binar
Se non scrive sullo `standard output', xxd scrive nel file di output in maniera
continua, senza interruzioni. Usare la combinazione
.I \-r \-p
per leggere dump in stile esadecimale semplice, senza l'informazione del numero
per leggere un dump in stile esadecimale semplice, senza l'informazione del numero
di riga e senza un particolare tracciato di colonna. Spazi o righe vuote
possono essere presenti [e vengono ignorati].
possono essere presenti dappertutto [e vengono ignorati]. Usare la combinazione
.I \-r \-b
per leggere un dump binario, invece che un dump esadecimale.
.TP
.IR \-R " "[quando]
Nell'output i valori esadecimali e i caratteri corrispondenti hanno entrambi

View File

@@ -131,9 +131,11 @@ Ricostruisce: converte (o mette una patch) da immagine esadecimale, a file binar
Se non scrive sullo `standard output', xxd scrive nel file di output in maniera
continua, senza interruzioni. Usare la combinazione
.I \-r \-p
per leggere dump in stile esadecimale semplice, senza l'informazione del numero
per leggere un dump in stile esadecimale semplice, senza l'informazione del numero
di riga e senza un particolare tracciato di colonna. Spazi o righe vuote
possono essere presenti [e vengono ignorati].
possono essere presenti dappertutto [e vengono ignorati]. Usare la combinazione
.I \-r \-b
per leggere un dump binario, invece che un dump esadecimale.
.TP
.IR \-R " "[quando]
Nell'output i valori esadecimali e i caratteri corrispondenti hanno entrambi

View File

@@ -1013,7 +1013,7 @@ au BufNewFile,BufRead ipf.conf,ipf6.conf,ipf.rules setf ipfilter
au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl setf fgl
" .INI file for MSDOS
au BufNewFile,BufRead *.ini setf dosini
au BufNewFile,BufRead *.ini,*.INI setf dosini
" SysV Inittab
au BufNewFile,BufRead inittab setf inittab

View File

@@ -1,7 +1,7 @@
" Vim filetype plugin file
" Language: gpg(1) configuration file
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2008-07-09
" Latest Revision: 2023-10-07
if exists("b:did_ftplugin")
finish
@@ -17,17 +17,17 @@ setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql
if has('unix') && executable('less')
if !has('gui_running')
command -buffer -nargs=1 Sman
command -buffer -nargs=1 GpgKeywordPrg
\ silent exe '!' . 'LESS= MANPAGER="less --pattern=''^\s+--' . <q-args> . '\b'' --hilite-search" man ' . 'gpg' |
\ redraw!
elseif has('terminal')
command -buffer -nargs=1 Sman
command -buffer -nargs=1 GpgKeywordPrg
\ silent exe ':term ' . 'env LESS= MANPAGER="less --pattern=''' . escape('^\s+--' . <q-args> . '\b', '\') . ''' --hilite-search" man ' . 'gpg'
endif
if exists(':Sman') == 2
if exists(':GpgKeywordPrg') == 2
setlocal iskeyword+=-
setlocal keywordprg=:Sman
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer Sman'
setlocal keywordprg=:GpgKeywordPrg
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer GpgKeywordPrg'
endif
endif

View File

@@ -1,7 +1,7 @@
" Vim filetype plugin file
" Language: modules.conf(5) configuration file
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2008-07-09
" Latest Revision: 2023-10-07
if exists("b:did_ftplugin")
finish
@@ -18,17 +18,17 @@ setlocal formatoptions-=t formatoptions+=croql
if has('unix') && executable('less')
if !has('gui_running')
command -buffer -nargs=1 Sman
command -buffer -nargs=1 ModconfKeywordPrg
\ silent exe '!' . 'LESS= MANPAGER="less --pattern=''^\s{,8}' . <q-args> . '\b'' --hilite-search" man ' . 'modprobe.d' |
\ redraw!
elseif has('terminal')
command -buffer -nargs=1 Sman
command -buffer -nargs=1 ModconfKeywordPrg
\ silent exe ':term ' . 'env LESS= MANPAGER="less --pattern=''' . escape('^\s{,8}' . <q-args> . '\b', '\') . ''' --hilite-search" man ' . 'modprobe.d'
endif
if exists(':Sman') == 2
if exists(':ModconfKeywordPrg') == 2
setlocal iskeyword+=-
setlocal keywordprg=:Sman
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer Sman'
setlocal keywordprg=:ModconfKeywordPrg
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer ModconfKeywordPrg'
endif
endif

View File

@@ -1,7 +1,7 @@
" Vim filetype plugin file
" Language: mutt RC File
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2006-04-19
" Latest Revision: 2023-10-07
if exists("b:did_ftplugin")
finish
@@ -20,17 +20,17 @@ let &l:include = '^\s*source\>'
if has('unix') && executable('less')
if !has('gui_running')
command -buffer -nargs=1 Sman
command -buffer -nargs=1 MuttrcKeywordPrg
\ silent exe '!' . 'LESS= MANPAGER="less --pattern=''^\s+' . <q-args> . '\b'' --hilite-search" man ' . 'muttrc' |
\ redraw!
elseif has('terminal')
command -buffer -nargs=1 Sman
command -buffer -nargs=1 MuttrcKeywordPrg
\ silent exe 'term ' . 'env LESS= MANPAGER="less --pattern=''' . escape('^\s+' . <q-args> . '\b', '\') . ''' --hilite-search" man ' . 'muttrc'
endif
if exists(':Sman') == 2
if exists(':MuttrcKeywordPrg') == 2
setlocal iskeyword+=-
setlocal keywordprg=:Sman
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer Sman'
setlocal keywordprg=:MuttrcKeywordPrg
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer MuttrcKeywordPrg'
endif
endif

View File

@@ -32,17 +32,17 @@ endif
if has('unix') && executable('less')
if !has('gui_running')
command -buffer -nargs=1 Sman
command -buffer -nargs=1 ReadlineKeywordPrg
\ silent exe '!' . 'LESS= MANPAGER="less --pattern=''^\s+' . <q-args> . '\b'' --hilite-search" man ' . '3 readline' |
\ redraw!
elseif has('terminal')
command -buffer -nargs=1 Sman
command -buffer -nargs=1 ReadlineKeywordPrg
\ silent exe 'term ' . 'env LESS= MANPAGER="less --pattern=''' . escape('^\s+' . <q-args> . '\b', '\') . ''' --hilite-search" man ' . '3 readline'
endif
if exists(':Sman') == 2
if exists(':ReadlineKeywordPrg') == 2
setlocal iskeyword+=-
setlocal keywordprg=:Sman
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer Sman'
setlocal keywordprg=:ReadlineKeywordPrg
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer ReadlineKeywordPrg'
endif
endif

View File

@@ -1,7 +1,7 @@
" Vim filetype plugin file
" Language: OpenSSH client configuration file
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2008-07-09
" Latest Revision: 2023-10-07
if exists("b:did_ftplugin")
finish
@@ -16,17 +16,17 @@ let b:undo_ftplugin = 'setlocal com< cms< fo<'
if has('unix') && executable('less')
if !has('gui_running')
command -buffer -nargs=1 Sman
command -buffer -nargs=1 SshconfigKeywordPrg
\ silent exe '!' . 'LESS= MANPAGER="less --pattern=''^\s+' . <q-args> . '$'' --hilite-search" man ' . 'ssh_config' |
\ redraw!
elseif has('terminal')
command -buffer -nargs=1 Sman
command -buffer -nargs=1 SshconfigKeywordPrg
\ silent exe 'term ' . 'env LESS= MANPAGER="less --pattern=''' . escape('^\s+' . <q-args> . '$', '\') . ''' --hilite-search" man ' . 'ssh_config'
endif
if exists(':Sman') == 2
if exists(':SshconfigKeywordPrg') == 2
setlocal iskeyword+=-
setlocal keywordprg=:Sman
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer Sman'
setlocal keywordprg=:SshconfigKeywordPrg
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer SshconfigKeywordPrg'
endif
endif

View File

@@ -1,7 +1,7 @@
" Vim filetype plugin file
" Language: sudoers(5) configuration files
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2008-07-09
" Latest Revision: 2023-10-07
if exists("b:did_ftplugin")
finish
@@ -17,17 +17,17 @@ setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql
if has('unix') && executable('less')
if !has('gui_running')
command -buffer -nargs=1 Sman
command -buffer -nargs=1 SudoersKeywordPrg
\ silent exe '!' . 'LESS= MANPAGER="less --pattern=''\b' . <q-args> . '\b'' --hilite-search" man ' . 'sudoers' |
\ redraw!
elseif has('terminal')
command -buffer -nargs=1 Sman
command -buffer -nargs=1 SudoersKeywordPrg
\ silent exe ':term ' . 'env LESS= MANPAGER="less --pattern=''' . escape('\b' . <q-args> . '\b', '\') . ''' --hilite-search" man ' . 'sudoers'
endif
if exists(':Sman') == 2
if exists(':SudoersKeywordPrg') == 2
setlocal iskeyword+=-
setlocal keywordprg=:Sman
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer Sman'
setlocal keywordprg=:SudoersKeywordPrg
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer SudoersKeywordPrg'
endif
endif

View File

@@ -1,6 +1,7 @@
" Vim filetype plugin file
" Language: systemd.unit(5)
" Keyword Lookup Support: Enno Nagel <enno.nagel+vim@gmail.com>
" Latest Revision: 2023-10-07
if !exists('b:did_ftplugin')
" Looks a lot like dosini files.
@@ -9,11 +10,11 @@ endif
if has('unix') && executable('less')
if !has('gui_running')
command -buffer -nargs=1 Sman silent exe '!' . KeywordLookup_systemd(<q-args>) | redraw!
command -buffer -nargs=1 SystemdKeywordPrg silent exe '!' . KeywordLookup_systemd(<q-args>) | redraw!
elseif has('terminal')
command -buffer -nargs=1 Sman silent exe 'term ' . KeywordLookup_systemd(<q-args>)
command -buffer -nargs=1 SystemdKeywordPrg silent exe 'term ' . KeywordLookup_systemd(<q-args>)
endif
if exists(':Sman') == 2
if exists(':SystemdKeywordPrg') == 2
if !exists('*KeywordLookup_systemd')
function KeywordLookup_systemd(keyword) abort
let matches = matchlist(getline(search('\v^\s*\[\s*.+\s*\]\s*$', 'nbWz')), '\v^\s*\[\s*(\k+).*\]\s*$')
@@ -26,11 +27,11 @@ if has('unix') && executable('less')
endfunction
endif
setlocal iskeyword+=-
setlocal keywordprg=:Sman
setlocal keywordprg=:SystemdKeywordPrg
if !exists('b:undo_ftplugin') || empty(b:undo_ftplugin)
let b:undo_ftplugin = 'setlocal keywordprg< iskeyword<'
else
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer Sman'
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer SystemdKeywordPrg'
endif
endif
endif

View File

@@ -1,7 +1,7 @@
" Vim filetype plugin file
" Language: udev(8) rules file
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2008-07-09
" Latest Revision: 2023-10-07
if exists("b:did_ftplugin")
finish
@@ -17,17 +17,17 @@ setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql
if has('unix') && executable('less')
if !has('gui_running')
command -buffer -nargs=1 Sman
command -buffer -nargs=1 UdevrulesKeywordPrg
\ silent exe '!' . 'LESS= MANPAGER="less --pattern=''^\s{,8}' . <q-args> . '\b'' --hilite-search" man ' . 'udev' |
\ redraw!
elseif has('terminal')
command -buffer -nargs=1 Sman
command -buffer -nargs=1 UdevrulesKeywordPrg
\ silent exe ':term ' . 'env LESS= MANPAGER="less --pattern=''' . escape('^\s{,8}' . <q-args> . '\b', '\') . ''' --hilite-search" man ' . 'udev'
endif
if exists(':Sman') == 2
if exists(':UdevrulesKeywordPrg') == 2
setlocal iskeyword+=-
setlocal keywordprg=:Sman
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer Sman'
setlocal keywordprg=:UdevrulesKeywordPrg
let b:undo_ftplugin .= '| setlocal keywordprg< iskeyword< | sil! delc -buffer UdevrulesKeywordPrg'
endif
endif

View File

@@ -2,7 +2,7 @@
" Language: Zsh shell script
" Maintainer: Christian Brabandt <cb@256bit.org>
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2021-04-03
" Latest Revision: 2023-10-07
" License: Vim (see :h license)
" Repository: https://github.com/chrisbra/vim-zsh
@@ -20,17 +20,17 @@ let b:undo_ftplugin = "setl com< cms< fo< "
if executable('zsh') && &shell !~# '/\%(nologin\|false\)$'
if !has('gui_running') && executable('less')
command! -buffer -nargs=1 RunHelp silent exe '!MANPAGER= zsh -c "autoload -Uz run-help; run-help <args> 2>/dev/null | LESS= less"' | redraw!
command! -buffer -nargs=1 ZshKeywordPrg silent exe '!MANPAGER= zsh -c "autoload -Uz run-help; run-help <args> 2>/dev/null | LESS= less"' | redraw!
elseif has('terminal')
command! -buffer -nargs=1 RunHelp silent exe ':term zsh -c "autoload -Uz run-help; run-help <args>"'
command! -buffer -nargs=1 ZshKeywordPrg silent exe ':term zsh -c "autoload -Uz run-help; run-help <args>"'
else
command! -buffer -nargs=1 RunHelp echo system('zsh -c "autoload -Uz run-help; run-help <args> 2>/dev/null"')
command! -buffer -nargs=1 ZshKeywordPrg echo system('zsh -c "autoload -Uz run-help; run-help <args> 2>/dev/null"')
endif
if !exists('current_compiler')
compiler zsh
endif
setlocal keywordprg=:RunHelp
let b:undo_ftplugin .= 'keywordprg< | sil! delc -buffer RunHelp'
setlocal keywordprg=:ZshKeywordPrg
let b:undo_ftplugin .= 'keywordprg< | sil! delc -buffer ZshKeywordPrg'
endif
let b:match_words = '\<if\>:\<elif\>:\<else\>:\<fi\>'

View File

@@ -6013,6 +6013,9 @@ buf_contents_changed(buf_T *buf)
return TRUE;
}
// We don't want to trigger autocommands now, they may have nasty
// side-effects like wiping buffers
block_autocmds();
if (ml_open(curbuf) == OK
&& readfile(buf->b_ffname, buf->b_fname,
(linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM,
@@ -6038,6 +6041,8 @@ buf_contents_changed(buf_T *buf)
if (curbuf != newbuf) // safety check
wipe_buffer(newbuf, FALSE);
unblock_autocmds();
return differ;
}

View File

@@ -113,9 +113,10 @@ wildescape(
for (int i = 0; i < numfiles; ++i)
{
// for ":set path=" we need to escape spaces twice
if (xp->xp_backslash == XP_BS_THREE)
if (xp->xp_backslash & XP_BS_THREE)
{
p = vim_strsave_escaped(files[i], (char_u *)" ");
char *pat = (xp->xp_backslash & XP_BS_COMMA) ? " ," : " ";
p = vim_strsave_escaped(files[i], (char_u *)pat);
if (p != NULL)
{
vim_free(files[i]);
@@ -130,6 +131,18 @@ wildescape(
#endif
}
}
else if (xp->xp_backslash & XP_BS_COMMA)
{
if (vim_strchr(files[i], ',') != NULL)
{
p = vim_strsave_escaped(files[i], (char_u *)",");
if (p != NULL)
{
vim_free(files[i]);
files[i] = p;
}
}
}
#ifdef BACKSLASH_IN_FILENAME
p = vim_strsave_fnameescape(files[i], vse_what);
#else
@@ -2730,14 +2743,23 @@ expand_files_and_dirs(
for (i = 0; pat[i]; ++i)
if (pat[i] == '\\')
{
if (xp->xp_backslash == XP_BS_THREE
if (xp->xp_backslash & XP_BS_THREE
&& pat[i + 1] == '\\'
&& pat[i + 2] == '\\'
&& pat[i + 3] == ' ')
STRMOVE(pat + i, pat + i + 3);
if (xp->xp_backslash == XP_BS_ONE
else if (xp->xp_backslash & XP_BS_ONE
&& pat[i + 1] == ' ')
STRMOVE(pat + i, pat + i + 1);
else if ((xp->xp_backslash & XP_BS_COMMA)
&& pat[i + 1] == '\\'
&& pat[i + 2] == ',')
STRMOVE(pat + i, pat + i + 2);
#ifdef BACKSLASH_IN_FILENAME
else if ((xp->xp_backslash & XP_BS_COMMA)
&& pat[i + 1] == ',')
STRMOVE(pat + i, pat + i + 1);
#endif
}
}

View File

@@ -1771,8 +1771,8 @@ EXTERN char e_less_targets_than_list_items[]
INIT(= N_("E687: Less targets than List items"));
EXTERN char e_more_targets_than_list_items[]
INIT(= N_("E688: More targets than List items"));
EXTERN char e_can_only_index_list_dictionary_or_blob[]
INIT(= N_("E689: Can only index a List, Dictionary or Blob"));
EXTERN char e_index_not_allowed_after_str_str[]
INIT(= N_("E689: Index not allowed after a %s: %s"));
EXTERN char e_missing_in_after_for[]
INIT(= N_("E690: Missing \"in\" after :for"));
EXTERN char e_can_only_compare_list_with_list[]
@@ -3081,8 +3081,8 @@ EXTERN char e_libsodium_decryption_failed_premature[]
#ifdef FEAT_EVAL
EXTERN char e_no_white_space_allowed_after_str_str[]
INIT(= N_("E1202: No white space allowed after '%s': %s"));
EXTERN char e_dot_can_only_be_used_on_dictionary_str[]
INIT(= N_("E1203: Dot can only be used on a dictionary: %s"));
EXTERN char e_dot_not_allowed_after_str_str[]
INIT(= N_("E1203: Dot not allowed after a %s: %s"));
#endif
EXTERN char e_regexp_number_after_dot_pos_search_chr[]
INIT(= N_("E1204: No Number allowed after .: '\\%%%c'"));

View File

@@ -1375,9 +1375,9 @@ get_lval(
&& v_type != VAR_OBJECT
&& v_type != VAR_CLASS)
{
// TODO: have a message with obj/class, not just dict,
if (!quiet)
semsg(_(e_dot_can_only_be_used_on_dictionary_str), name);
semsg(_(e_dot_not_allowed_after_str_str),
vartype_name(v_type), name);
return NULL;
}
if (v_type != VAR_LIST
@@ -1386,9 +1386,9 @@ get_lval(
&& v_type != VAR_OBJECT
&& v_type != VAR_CLASS)
{
// TODO: have a message with obj/class, not just dict/list/blob,
if (!quiet)
emsg(_(e_can_only_index_list_dictionary_or_blob));
semsg(_(e_index_not_allowed_after_str_str),
vartype_name(v_type), name);
return NULL;
}

View File

@@ -1753,7 +1753,12 @@ scrolldown(
++row;
}
if (col > width2 && width2 > 0)
{
row += col / width2;
// even so col is not used anymore,
// make sure it is correct, just in case
col = col % width2;
}
if (row >= curwin->w_height)
{
curwin->w_curswant = curwin->w_virtcol
@@ -1986,7 +1991,12 @@ adjust_skipcol(void)
++row;
}
if (col > width2)
{
row += col / width2;
// col may no longer be used, but make
// sure it is correct anyhow, just in case
col = col % width2;
}
if (row >= curwin->w_height)
{
if (curwin->w_skipcol == 0)

View File

@@ -7451,6 +7451,8 @@ set_context_in_set_cmd(
else
xp->xp_backslash = XP_BS_ONE;
}
if (flags & P_COMMA)
xp->xp_backslash |= XP_BS_COMMA;
}
// For an option that is a list of file names, or comma/colon-separated
@@ -7469,8 +7471,12 @@ set_context_in_set_cmd(
s = p;
while (s > xp->xp_pattern && *(s - 1) == '\\')
--s;
if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
|| (*p == ',' && (flags & P_COMMA) && ((p - s) % 1) == 0)
if ((*p == ' ' && ((xp->xp_backslash & XP_BS_THREE) && (p - s) < 3))
#if defined(BACKSLASH_IN_FILENAME)
|| (*p == ',' && (flags & P_COMMA) && (p - s) < 1)
#else
|| (*p == ',' && (flags & P_COMMA) && (p - s) < 2)
#endif
|| (*p == ':' && (flags & P_COLON)))
{
xp->xp_pattern = p + 1;

View File

@@ -10,11 +10,8 @@ ufunc_T *find_class_func(char_u **arg);
int class_member_idx(class_T *cl, char_u *name, size_t namelen);
ocmember_T *class_member_lookup(class_T *cl, char_u *name, size_t namelen, int *idx);
int class_method_idx(class_T *cl, char_u *name, size_t namelen);
ufunc_T *class_method_lookup(class_T *cl, char_u *name, size_t namelen, int *idx);
int object_member_idx(class_T *cl, char_u *name, size_t namelen);
ocmember_T *object_member_lookup(class_T *cl, char_u *name, size_t namelen, int *idx);
int object_method_idx(class_T *cl, char_u *name, size_t namelen);
ufunc_T *object_method_lookup(class_T *cl, char_u *name, size_t namelen, int *idx);
ocmember_T *member_lookup(class_T *cl, vartype_T v_type, char_u *name, size_t namelen, int *idx);
void emsg_var_cl_define(char *msg, char_u *name, size_t len, class_T *cl);
ufunc_T *method_lookup(class_T *cl, vartype_T v_type, char_u *name, size_t namelen, int *idx);
@@ -26,7 +23,6 @@ void class_unref(class_T *cl);
int class_free_nonref(int copyID);
int set_ref_in_classes(int copyID);
void object_created(object_T *obj);
void object_cleared(object_T *obj);
int object_free_nonref(int copyID);
void method_not_found_msg(class_T *cl, vartype_T v_type, char_u *name, size_t len);
void member_not_found_msg(class_T *cl, vartype_T v_type, char_u *name, size_t len);

View File

@@ -631,8 +631,9 @@ typedef struct expand
* values for xp_backslash
*/
#define XP_BS_NONE 0 // nothing special for backslashes
#define XP_BS_ONE 1 // uses one backslash before a space
#define XP_BS_THREE 2 // uses three backslashes before a space
#define XP_BS_ONE 0x1 // uses one backslash before a space
#define XP_BS_THREE 0x2 // uses three backslashes before a space
#define XP_BS_COMMA 0x4 // commas need to be escaped with a backslash
/*
* Variables shared between getcmdline(), redrawcmdline() and others.

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@@ -1257,13 +1257,71 @@ func Test_cmdline_complete_various()
mapclear
delcom MyCmd
" Prepare for path completion
call mkdir('Xa b c', 'D')
defer delete('Xcomma,foobar.txt')
call writefile([], 'Xcomma,foobar.txt')
" completion for :set path= with multiple backslashes
call feedkeys(":set path=a\\\\\\ b\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set path=a\\\ b', @:)
call feedkeys(':set path=Xa\\\ b' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set path=Xa\\\ b\\\ c/', @:)
set path&
" completion for :set dir= with a backslash
call feedkeys(":set dir=a\\ b\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set dir=a\ b', @:)
call feedkeys(':set dir=Xa\ b' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set dir=Xa\ b\ c/', @:)
set dir&
" completion for :set tags= / set dictionary= with escaped commas
if has('win32')
" In Windows backslashes are rounded up, so both '\,' and '\\,' escape to
" '\,'
call feedkeys(':set dictionary=Xcomma\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set dictionary=Xcomma\,foobar.txt', @:)
call feedkeys(':set tags=Xcomma\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set tags=Xcomma\,foobar.txt', @:)
call feedkeys(':set tags=Xcomma\\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set tags=Xcomma\\\,foo', @:) " Didn't find a match
" completion for :set dictionary= with escaped commas (same behavior, but
" different internal code path from 'set tags=' for escaping the output)
call feedkeys(':set tags=Xcomma\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set tags=Xcomma\,foobar.txt', @:)
else
" In other platforms, backslashes are rounded down (since '\,' itself will
" be escaped into ','). As a result '\\,' and '\\\,' escape to '\,'.
call feedkeys(':set tags=Xcomma\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set tags=Xcomma\,foo', @:) " Didn't find a match
call feedkeys(':set tags=Xcomma\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set tags=Xcomma\\,foobar.txt', @:)
call feedkeys(':set dictionary=Xcomma\\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set dictionary=Xcomma\\,foobar.txt', @:)
" completion for :set dictionary= with escaped commas (same behavior, but
" different internal code path from 'set tags=' for escaping the output)
call feedkeys(':set dictionary=Xcomma\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set dictionary=Xcomma\\,foobar.txt', @:)
endif
set tags&
set dictionary&
" completion for :set makeprg= with no escaped commas
call feedkeys(':set makeprg=Xcomma,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set makeprg=Xcomma,foobar.txt', @:)
if !has('win32')
" Cannot create file with backslash in file name in Windows, so only test
" this elsewhere.
defer delete('Xcomma\,fooslash.txt')
call writefile([], 'Xcomma\,fooslash.txt')
call feedkeys(':set makeprg=Xcomma\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set makeprg=Xcomma\\,fooslash.txt', @:)
endif
set makeprg&
" completion for the :py3 commands
call feedkeys(":py3\<C-A>\<C-B>\"\<CR>", 'xt')

View File

@@ -78,6 +78,14 @@ func Test_crash1()
\ ' && echo "crash 9: [OK]" >> X_crash1_result.txt' .. "\<cr>")
call TermWait(buf, 1000)
let file = 'crash/editing_arg_idx_POC_1'
let args = printf(cmn_args, vim, file)
call term_sendkeys(buf, args ..
\ ' || echo "crash 10: [OK]" >> X_crash1_result.txt' .. "\<cr>")
call TermWait(buf, 1000)
call delete('Xerr')
call delete('@')
" clean up
exe buf .. "bw!"
@@ -93,6 +101,7 @@ func Test_crash1()
\ 'crash 7: [OK]',
\ 'crash 8: [OK]',
\ 'crash 9: [OK]',
\ 'crash 10: [OK]',
\ ]
call assert_equal(expected, getline(1, '$'))

View File

@@ -206,7 +206,7 @@ def s:GetFilenameChecks(): dict<list<string>>
dnsmasq: ['/etc/dnsmasq.conf', '/etc/dnsmasq.d/file', 'any/etc/dnsmasq.conf', 'any/etc/dnsmasq.d/file'],
dockerfile: ['Containerfile', 'Dockerfile', 'dockerfile', 'file.Dockerfile', 'file.dockerfile', 'Dockerfile.debian', 'Containerfile.something'],
dosbatch: ['file.bat'],
dosini: ['/etc/yum.conf', 'file.ini', 'npmrc', '.npmrc', 'php.ini', 'php.ini-5', 'php.ini-file', '/etc/yum.repos.d/file', 'any/etc/yum.conf', 'any/etc/yum.repos.d/file', 'file.wrap', 'file.vbp'],
dosini: ['/etc/yum.conf', 'file.ini', 'npmrc', '.npmrc', 'php.ini', 'php.ini-5', 'php.ini-file', '/etc/yum.repos.d/file', 'any/etc/yum.conf', 'any/etc/yum.repos.d/file', 'file.wrap', 'file.vbp', 'ja2.ini', 'JA2.INI'],
dot: ['file.dot', 'file.gv'],
dracula: ['file.drac', 'file.drc', 'filelvs', 'filelpe', 'drac.file', 'lpe', 'lvs', 'some-lpe', 'some-lvs'],
dtd: ['file.dtd'],

View File

@@ -435,13 +435,13 @@ func Test_dict_assign()
let n = 0
let n.key = 3
END
call v9.CheckScriptFailure(lines, 'E1203: Dot can only be used on a dictionary: n.key = 3')
call v9.CheckScriptFailure(lines, 'E1203: Dot not allowed after a number: n.key = 3')
let lines =<< trim END
vim9script
var n = 0
n.key = 3
END
call v9.CheckScriptFailure(lines, 'E1203: Dot can only be used on a dictionary: n.key = 3')
call v9.CheckScriptFailure(lines, 'E1203: Dot not allowed after a number: n.key = 3')
let lines =<< trim END
var n = 0
n.key = 3

View File

@@ -314,6 +314,7 @@ func Test_set_completion()
call feedkeys(":set cdpath=./\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_match(' ./samples/ ', @:)
call assert_notmatch(' ./summarize.vim ', @:)
set cdpath&
" Expand files and directories.
call feedkeys(":set tags=./\<C-A>\<C-B>\"\<CR>", 'tx')
@@ -321,7 +322,50 @@ func Test_set_completion()
call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:)
set tags&
" Expand files with spaces/commas in them. Make sure we delimit correctly.
"
" 'tags' allow for for spaces/commas to both act as delimiters, with actual
" spaces requiring double escape, and commas need a single escape.
" 'dictionary' is a normal comma-separated option where only commas act as
" delimiters, and both space/comma need one single escape.
" 'makeprg' is a non-comma-separated option. Commas don't need escape.
defer delete('Xfoo Xspace.txt')
defer delete('Xsp_dummy')
defer delete('Xbar,Xcomma.txt')
defer delete('Xcom_dummy')
call writefile([], 'Xfoo Xspace.txt')
call writefile([], 'Xsp_dummy')
call writefile([], 'Xbar,Xcomma.txt')
call writefile([], 'Xcom_dummy')
call feedkeys(':set tags=./Xfoo\ Xsp' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set tags=./Xfoo\ Xsp_dummy', @:)
call feedkeys(':set tags=./Xfoo\\\ Xsp' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set tags=./Xfoo\\\ Xspace.txt', @:)
call feedkeys(':set dictionary=./Xfoo\ Xsp' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set dictionary=./Xfoo\ Xspace.txt', @:)
call feedkeys(':set dictionary=./Xbar,Xcom' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set dictionary=./Xbar,Xcom_dummy', @:)
if has('win32')
" In Windows, '\,' is literal, see `:help filename-backslash`, so this
" means we treat it as one file name.
call feedkeys(':set dictionary=Xbar\,Xcom' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set dictionary=Xbar\,Xcomma.txt', @:)
else
" In other platforms, '\,' simply escape to ',', and indicate a delimiter
" to split into a separate file name. You need '\\,' to escape the comma
" as part of the file name.
call feedkeys(':set dictionary=Xbar\,Xcom' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set dictionary=Xbar\,Xcom_dummy', @:)
call feedkeys(':set dictionary=Xbar\\,Xcom' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set dictionary=Xbar\\,Xcomma.txt', @:)
endif
call feedkeys(":set makeprg=./Xbar,Xcom\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set makeprg=./Xbar,Xcomma.txt', @:)
set tags& dictionary& makeprg&
" Expanding the option names
call feedkeys(":set \<Tab>\<C-B>\"\<CR>", 'xt')

View File

@@ -860,6 +860,7 @@ func Test_undo_after_write()
call StopVimInTerminal(buf)
call delete('Xtestfile.txt')
call delete('.Xtestfile.txt.un~')
endfunc
func Test_undo_range_normal()

View File

@@ -1278,7 +1278,7 @@ def Test_assignment_dict()
var n: any
n.key = 5
END
v9.CheckDefExecAndScriptFailure(lines, ['E1148:', 'E1203: Dot can only be used on a dictionary: n.key = 5'], 2)
v9.CheckDefExecAndScriptFailure(lines, ['E1148:', 'E1203: Dot not allowed after a number: n.key = 5'], 2)
enddef
def Test_assignment_local()

View File

@@ -975,6 +975,28 @@ def Test_class_new_with_object_member()
Check()
END
v9.CheckSourceSuccess(lines)
# Try using "this." argument in a class method
lines =<< trim END
vim9script
class A
this.val = 10
static def Foo(this.val: number)
enddef
endclass
END
v9.CheckSourceFailure(lines, 'E1390: Cannot use an object variable "this.val" except with the "new" method', 4)
# Try using "this." argument in an object method
lines =<< trim END
vim9script
class A
this.val = 10
def Foo(this.val: number)
enddef
endclass
END
v9.CheckSourceFailure(lines, 'E1390: Cannot use an object variable "this.val" except with the "new" method', 4)
enddef
def Test_class_object_member_inits()
@@ -1722,7 +1744,7 @@ def Test_class_member()
var a = A.new()
var v = a.bar
END
v9.CheckSourceFailure(lines, 'E1326: Variable not found on object "A": bar', 5)
v9.CheckSourceFailure(lines, 'E1337: Class variable "bar" not found in class "A"', 5)
enddef
" These messages should show the defining class of the variable (base class),
@@ -4255,7 +4277,7 @@ def Test_private_object_method()
var a = A.new()
a._Foo()
END
v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 9)
v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 9)
# Try calling a private method using an object (from a def function)
lines =<< trim END
@@ -4468,7 +4490,7 @@ def Test_private_object_method()
var c = C.new()
assert_equal(1234, c._Foo())
END
v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 16)
v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 16)
# Using "_" prefix in a method name should fail outside of a class
lines =<< trim END
@@ -4494,7 +4516,7 @@ def Test_private_class_method()
endclass
A._Foo()
END
v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 8)
v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 8)
# Try calling a class private method (from a def function)
lines =<< trim END
@@ -5122,7 +5144,7 @@ def Test_class_variable_access_using_object()
var a = A.new()
echo a.svar2
END
v9.CheckSourceFailure(lines, 'E1375: Class variable "svar2" accessible only using class "A"', 8)
v9.CheckSourceFailure(lines, 'E1337: Class variable "svar2" not found in class "A"', 8)
# Cannot write to a class variable using an object in script context
lines =<< trim END
@@ -5597,7 +5619,7 @@ def Test_class_variable()
var a = A.new()
var i = a.val
END
v9.CheckSourceFailure(lines, 'E1375: Class variable "val" accessible only using class "A"', 7)
v9.CheckSourceFailure(lines, 'E1337: Class variable "val" not found in class "A"', 7)
# Modifying a class variable using an object at function level
lines =<< trim END
@@ -5969,6 +5991,18 @@ def Test_extend_interface()
END
v9.CheckSourceSuccess(lines)
# extending empty interface
lines =<< trim END
vim9script
interface A
endinterface
interface B extends A
endinterface
class C implements B
endclass
END
v9.CheckSourceSuccess(lines)
lines =<< trim END
vim9script
interface A
@@ -6567,6 +6601,17 @@ def Test_reserved_varname()
o.F()
END
v9.CheckSourceFailure(lines, $'E1034: Cannot use reserved name {kword}', 3)
# class variable name
if kword != 'this'
lines =<< trim eval END
vim9script
class C
public static {kword}: list<number> = [1, 2, 3]
endclass
END
v9.CheckSourceFailure(lines, $'E1034: Cannot use reserved name {kword}', 3)
endif
endfor
enddef
@@ -7109,4 +7154,41 @@ def Test_recursive_class_method_call()
v9.CheckSourceSuccess(lines)
enddef
" Test for checking the argument types and the return type when assigning a
" funcref to make sure the invariant class type is used.
def Test_funcref_argtype_returntype_check()
var lines =<< trim END
vim9script
class A
endclass
class B extends A
endclass
def Foo(p: B): B
return B.new()
enddef
var Bar: func(A): A = Foo
END
v9.CheckSourceFailure(lines, 'E1012: Type mismatch; expected func(object<A>): object<A> but got func(object<B>): object<B>', 11)
lines =<< trim END
vim9script
class A
endclass
class B extends A
endclass
def Foo(p: B): B
return B.new()
enddef
def Baz()
var Bar: func(A): A = Foo
enddef
Baz()
END
v9.CheckSourceFailure(lines, 'E1012: Type mismatch; expected func(object<A>): object<A> but got func(object<B>): object<B>', 1)
enddef
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker

View File

@@ -488,6 +488,8 @@ if has('job')
var Pp = null_partial
var jj = null_job
var cc = null_channel
var oo = null_object
var nc = null_class
enddef
def Test_disassemble_assign_null()
@@ -525,6 +527,14 @@ if has('job')
'\d\+ PUSHCHANNEL 0\_s*' ..
'\d\+ STORE $\d\_s*' ..
'var oo = null_object\_s*' ..
'\d\+ PUSHOBJ null\_s*' ..
'\d\+ STORE $\d\_s*' ..
'var nc = null_class\_s*' ..
'\d\+ PUSHCLASS null\_s*' ..
'\d\+ STORE $\d\_s*' ..
'\d\+ RETURN void',
res)
enddef
@@ -2968,7 +2978,7 @@ def BitShift()
var a = 1 << 2
var b = 8 >> 1
var c = a << b
var d = b << a
var d = b >> a
enddef
def Test_disassemble_bitshift()
@@ -2983,10 +2993,10 @@ def Test_disassemble_bitshift()
'3 LOAD $1\_s*' ..
'4 OPNR <<\_s*' ..
'5 STORE $2\_s*' ..
'var d = b << a\_s*' ..
'var d = b >> a\_s*' ..
'6 LOAD $1\_s*' ..
'7 LOAD $0\_s*' ..
'8 OPNR <<\_s*' ..
'8 OPNR >>\_s*' ..
'9 STORE $3\_s*' ..
'10 RETURN void', instr)
enddef
@@ -3108,4 +3118,167 @@ def Test_disassemble_interface_static_member()
unlet g:instr2
enddef
" Disassemble instructions for loading and storing class variables
def Test_disassemble_class_variable()
var lines =<< trim END
vim9script
class A
public static val = 10
def Foo(): number
val = 20
return val
enddef
endclass
g:instr = execute('disassemble A.Foo')
END
v9.CheckScriptSuccess(lines)
assert_match('Foo\_s*' ..
'val = 20\_s*' ..
'0 PUSHNR 20\_s*' ..
'1 STORE CLASSMEMBER A.val\_s*' ..
'return val\_s*' ..
'2 LOAD CLASSMEMBER A.val\_s*' ..
'3 RETURN', g:instr)
unlet g:instr
enddef
" Disassemble instructions for METHODCALL
def Test_disassemble_methodcall()
var lines =<< trim END
vim9script
interface A
def Foo()
endinterface
def Bar(a: A)
a.Foo()
enddef
g:instr = execute('disassemble Bar')
END
v9.CheckScriptSuccess(lines)
assert_match('<SNR>\d*_Bar\_s*' ..
'a.Foo()\_s*' ..
'0 LOAD arg\[-1\]\_s*' ..
'1 METHODCALL A.Foo(argc 0)\_s*' ..
'2 DROP\_s*' ..
'3 RETURN void', g:instr)
unlet g:instr
enddef
" Disassemble instructions for ISN_JUMP_IF_ARG_NOT_SET
def Test_disassemble_ifargnotset()
var lines =<< trim END
vim9script
class A
this.val: number = 10
endclass
g:instr = execute('disassemble A.new')
END
v9.CheckScriptSuccess(lines)
assert_match('new\_s*' ..
'0 NEW A size \d\+\_s*' ..
'1 PUSHNR 10\_s*' ..
'2 STORE_THIS 0\_s*' ..
'ifargisset 0 this.val = val\_s*' ..
'3 JUMP_IF_ARG_NOT_SET arg\[-1\] -> 8\_s*' ..
'4 LOAD arg\[-1\]\_s*' ..
'5 PUSHNR 0\_s*' ..
'6 LOAD $0\_s*' ..
'7 STOREINDEX object\_s*' ..
'8 RETURN object', g:instr)
unlet g:instr
enddef
" Disassemble instructions for ISN_COMPARECLASS and ISN_COMPAREOBJECT
def Test_disassemble_compare_class_object()
var lines =<< trim END
vim9script
class A
endclass
class B
endclass
def Foo(a: A, b: B)
if A == B
endif
if a == b
endif
enddef
g:instr = execute('disassemble Foo')
END
v9.CheckScriptSuccess(lines)
assert_match('<SNR>\d*_Foo\_s*' ..
'if A == B\_s*' ..
'0 LOADSCRIPT A-0 from .*\_s*' ..
'1 LOADSCRIPT B-1 from .*\_s*' ..
'2 COMPARECLASS ==\_s*' ..
'3 JUMP_IF_FALSE -> 4\_s*' ..
'endif\_s*' ..
'if a == b\_s*' ..
'4 LOAD arg\[-2\]\_s*' ..
'5 LOAD arg\[-1\]\_s*' ..
'6 COMPAREOBJECT ==\_s*' ..
'7 JUMP_IF_FALSE -> 8\_s*' ..
'endif\_s*' ..
'8 RETURN void', g:instr)
unlet g:instr
enddef
" Disassemble instructions for ISN_CHECKTYPE with a float|number
def Test_checktype_float()
var lines =<< trim END
vim9script
def Foo()
var f: float = 0.0
var a: any
f += a
enddef
g:instr = execute('disassemble Foo')
END
v9.CheckScriptSuccess(lines)
assert_match('<SNR>\d*_Foo\_s*' ..
'var f: float = 0.0\_s*' ..
'0 PUSHF 0.0\_s*' ..
'1 STORE $0\_s*' ..
'var a: any\_s*' ..
'f += a\_s*' ..
'2 LOAD $0\_s*' ..
'3 LOAD $1\_s*' ..
'4 CHECKTYPE float|number stack\[-1\]\_s*' ..
'5 OPANY +\_s*' ..
'6 STORE $0\_s*' ..
'7 RETURN void', g:instr)
unlet g:instr
enddef
" Disassemble instructions for ISN_FUNCREF with a class
def Test_funcref_with_class()
var lines =<< trim END
vim9script
class A
def Foo()
enddef
endclass
class B extends A
def Foo()
enddef
endclass
def Bar(a: A)
defer a.Foo()
enddef
g:instr = execute('disassemble Bar')
END
v9.CheckScriptSuccess(lines)
assert_match('<SNR>\d*_Bar\_s*' ..
'defer a.Foo()\_s*' ..
'0 LOAD arg\[-1\]\_s*' ..
'1 FUNCREF A.Foo\_s*' ..
'2 DEFEROBJ 0 args\_s*' ..
'3 RETURN void', g:instr)
unlet g:instr
enddef
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker

View File

@@ -704,6 +704,28 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2012,
/**/
2011,
/**/
2010,
/**/
2009,
/**/
2008,
/**/
2007,
/**/
2006,
/**/
2005,
/**/
2004,
/**/
2003,
/**/
2002,
/**/
2001,
/**/

View File

@@ -555,7 +555,6 @@ validate_abstract_class_methods(
intf_variable_present(
char_u *intf_class_name,
ocmember_T *if_var,
int is_class_var,
ocmember_T *cl_mt,
int cl_member_count,
class_T *extends_cl)
@@ -600,15 +599,10 @@ intf_variable_present(
if (!variable_present && extends_cl != NULL)
{
int ext_cl_count = is_class_var
? extends_cl->class_class_member_count
: extends_cl->class_obj_member_count;
ocmember_T *ext_cl_mt = is_class_var
? extends_cl->class_class_members
: extends_cl->class_obj_members;
int ext_cl_count = extends_cl->class_obj_member_count;
ocmember_T *ext_cl_mt = extends_cl->class_obj_members;
return intf_variable_present(intf_class_name, if_var,
is_class_var, ext_cl_mt,
ext_cl_count,
ext_cl_mt, ext_cl_count,
extends_cl->class_extends);
}
@@ -616,43 +610,32 @@ intf_variable_present(
}
/*
* Check the variables of the interface class "ifcl" match the class variables
* ("classmembers_gap") and object variables ("objmembers_gap") of a class.
* Returns TRUE if the class and object variables names are valid.
* Check the variables of the interface class "ifcl" match object variables
* ("objmembers_gap") of a class.
* Returns TRUE if the object variables names are valid.
*/
static int
validate_interface_variables(
char_u *intf_class_name,
class_T *ifcl,
garray_T *classmembers_gap,
garray_T *objmembers_gap,
class_T *extends_cl)
{
for (int loop = 1; loop <= 2; ++loop)
int if_count = ifcl->class_obj_member_count;
if (if_count == 0)
return TRUE;
ocmember_T *if_ms = ifcl->class_obj_members;
ocmember_T *cl_ms = (ocmember_T *)(objmembers_gap->ga_data);
int cl_count = objmembers_gap->ga_len;
for (int if_i = 0; if_i < if_count; ++if_i)
{
// loop == 1: check class variables
// loop == 2: check object variables
int is_class_var = (loop == 1);
int if_count = is_class_var ? ifcl->class_class_member_count
: ifcl->class_obj_member_count;
if (if_count == 0)
continue;
ocmember_T *if_ms = is_class_var ? ifcl->class_class_members
: ifcl->class_obj_members;
ocmember_T *cl_ms = (ocmember_T *)(is_class_var
? classmembers_gap->ga_data
: objmembers_gap->ga_data);
int cl_count = is_class_var ? classmembers_gap->ga_len
: objmembers_gap->ga_len;
for (int if_i = 0; if_i < if_count; ++if_i)
if (!intf_variable_present(intf_class_name, &if_ms[if_i], cl_ms,
cl_count, extends_cl))
{
if (!intf_variable_present(intf_class_name, &if_ms[if_i],
is_class_var, cl_ms, cl_count, extends_cl))
{
semsg(_(e_variable_str_of_interface_str_not_implemented),
if_ms[if_i].ocm_name, intf_class_name);
return FALSE;
}
semsg(_(e_variable_str_of_interface_str_not_implemented),
if_ms[if_i].ocm_name, intf_class_name);
return FALSE;
}
}
@@ -685,7 +668,6 @@ intf_method_type_matches(ufunc_T *if_method, ufunc_T *cl_method)
static int
intf_method_present(
ufunc_T *if_ufunc,
int is_class_method,
ufunc_T **cl_fp,
int cl_count,
class_T *extends_cl)
@@ -707,15 +689,10 @@ intf_method_present(
if (!method_present && extends_cl != NULL)
{
ufunc_T **ext_cl_fp = (ufunc_T **)(is_class_method
? extends_cl->class_class_functions
: extends_cl->class_obj_methods);
int ext_cl_count = is_class_method
? extends_cl->class_class_function_count
: extends_cl->class_obj_method_count;
return intf_method_present(if_ufunc, is_class_method, ext_cl_fp,
ext_cl_count,
extends_cl->class_extends);
ufunc_T **ext_cl_fp = (ufunc_T **)(extends_cl->class_obj_methods);
int ext_cl_count = extends_cl->class_obj_method_count;
return intf_method_present(if_ufunc, ext_cl_fp, ext_cl_count,
extends_cl->class_extends);
}
return method_present;
@@ -733,37 +710,25 @@ intf_method_present(
validate_interface_methods(
char_u *intf_class_name,
class_T *ifcl,
garray_T *classfunctions_gap,
garray_T *objmethods_gap,
class_T *extends_cl)
{
for (int loop = 1; loop <= 2; ++loop)
{
// loop == 1: check class methods
// loop == 2: check object methods
int is_class_method = (loop == 1);
int if_count = is_class_method ? ifcl->class_class_function_count
: ifcl->class_obj_method_count;
if (if_count == 0)
continue;
ufunc_T **if_fp = is_class_method ? ifcl->class_class_functions
: ifcl->class_obj_methods;
ufunc_T **cl_fp = (ufunc_T **)(is_class_method
? classfunctions_gap->ga_data
: objmethods_gap->ga_data);
int cl_count = is_class_method ? classfunctions_gap->ga_len
: objmethods_gap->ga_len;
for (int if_i = 0; if_i < if_count; ++if_i)
{
char_u *if_name = if_fp[if_i]->uf_name;
int if_count = ifcl->class_obj_method_count;
if (if_count == 0)
return TRUE;
if (!intf_method_present(if_fp[if_i], is_class_method, cl_fp,
cl_count, extends_cl))
{
semsg(_(e_method_str_of_interface_str_not_implemented),
if_name, intf_class_name);
return FALSE;
}
ufunc_T **if_fp = ifcl->class_obj_methods;
ufunc_T **cl_fp = (ufunc_T **)(objmethods_gap->ga_data);
int cl_count = objmethods_gap->ga_len;
for (int if_i = 0; if_i < if_count; ++if_i)
{
char_u *if_name = if_fp[if_i]->uf_name;
if (!intf_method_present(if_fp[if_i], cl_fp, cl_count, extends_cl))
{
semsg(_(e_method_str_of_interface_str_not_implemented),
if_name, intf_class_name);
return FALSE;
}
}
@@ -781,8 +746,6 @@ validate_interface_methods(
validate_implements_classes(
garray_T *impl_gap,
class_T **intf_classes,
garray_T *classfunctions_gap,
garray_T *classmembers_gap,
garray_T *objmethods_gap,
garray_T *objmembers_gap,
class_T *extends_cl)
@@ -816,15 +779,14 @@ validate_implements_classes(
++ifcl->class_refcount;
// check the variables of the interface match the members of the class
success = validate_interface_variables(impl, ifcl, classmembers_gap,
objmembers_gap, extends_cl);
success = validate_interface_variables(impl, ifcl, objmembers_gap,
extends_cl);
// check the functions/methods of the interface match the
// functions/methods of the class
if (success)
success = validate_interface_methods(impl, ifcl,
classfunctions_gap, objmethods_gap,
extends_cl);
success = validate_interface_methods(impl, ifcl, objmethods_gap,
extends_cl);
clear_tv(&tv);
}
@@ -1873,9 +1835,7 @@ early_ret:
intf_classes = ALLOC_CLEAR_MULT(class_T *, ga_impl.ga_len);
success = validate_implements_classes(&ga_impl, intf_classes,
&classfunctions, &classmembers,
&objmethods, &objmembers,
extends_cl);
&objmethods, &objmembers, extends_cl);
}
// Check no function argument name is used as a class member.
@@ -2172,18 +2132,90 @@ get_member_tv(
return FAIL;
}
// The object only contains a pointer to the class, the member
// values array follows right after that.
object_T *obj = rettv->vval.v_object;
if (is_object)
{
// The object only contains a pointer to the class, the member values
// array follows right after that.
object_T *obj = rettv->vval.v_object;
typval_T *tv = (typval_T *)(obj + 1) + m_idx;
copy_tv(tv, rettv);
object_unref(obj);
}
else
{
copy_tv(&cl->class_members_tv[m_idx], rettv);
class_unref(cl);
}
object_unref(obj);
return OK;
}
/*
* Call an object or class method "name" in class "cl". The method return
* value is returned in "rettv".
*/
static int
call_oc_method(
class_T *cl,
char_u *name,
size_t len,
char_u *name_end,
evalarg_T *evalarg,
char_u **arg,
typval_T *rettv)
{
ufunc_T *fp;
typval_T argvars[MAX_FUNC_ARGS + 1];
int argcount = 0;
fp = method_lookup(cl, rettv->v_type, name, len, NULL);
if (fp == NULL)
{
method_not_found_msg(cl, rettv->v_type, name, len);
return FAIL;
}
if (*fp->uf_name == '_')
{
// Cannot access a private method outside of a class
semsg(_(e_cannot_access_private_method_str), fp->uf_name);
return FAIL;
}
char_u *argp = name_end;
int ret = get_func_arguments(&argp, evalarg, 0, argvars, &argcount);
if (ret == FAIL)
return FAIL;
funcexe_T funcexe;
CLEAR_FIELD(funcexe);
funcexe.fe_evaluate = TRUE;
if (rettv->v_type == VAR_OBJECT)
{
funcexe.fe_object = rettv->vval.v_object;
++funcexe.fe_object->obj_refcount;
}
// Clear the class or object after calling the function, in
// case the refcount is one.
typval_T tv_tofree = *rettv;
rettv->v_type = VAR_UNKNOWN;
// Call the user function. Result goes into rettv;
int error = call_user_func_check(fp, argcount, argvars, rettv, &funcexe,
NULL);
// Clear the previous rettv and the arguments.
clear_tv(&tv_tofree);
for (int idx = 0; idx < argcount; ++idx)
clear_tv(&argvars[idx]);
if (error != FCERR_NONE)
{
user_func_error(error, printable_func_name(fp), funcexe.fe_found_var);
return FAIL;
}
*arg = argp;
return OK;
}
@@ -2242,104 +2274,22 @@ class_object_index(
}
if (*name_end == '(')
{
ufunc_T *fp;
// Invoke the class or object method
return call_oc_method(cl, name, len, name_end, evalarg, arg, rettv);
fp = method_lookup(cl, rettv->v_type, name, len, NULL);
if (fp == NULL)
{
method_not_found_msg(cl, rettv->v_type, name, len);
return FAIL;
}
typval_T argvars[MAX_FUNC_ARGS + 1];
int argcount = 0;
if (*fp->uf_name == '_')
{
// Cannot access a private method outside of a class
semsg(_(e_cannot_access_private_method_str), name);
return FAIL;
}
char_u *argp = name_end;
int ret = get_func_arguments(&argp, evalarg, 0,
argvars, &argcount);
if (ret == FAIL)
return FAIL;
funcexe_T funcexe;
CLEAR_FIELD(funcexe);
funcexe.fe_evaluate = TRUE;
if (rettv->v_type == VAR_OBJECT)
{
funcexe.fe_object = rettv->vval.v_object;
++funcexe.fe_object->obj_refcount;
}
// Clear the class or object after calling the function, in
// case the refcount is one.
typval_T tv_tofree = *rettv;
rettv->v_type = VAR_UNKNOWN;
// Call the user function. Result goes into rettv;
int error = call_user_func_check(fp, argcount, argvars,
rettv, &funcexe, NULL);
// Clear the previous rettv and the arguments.
clear_tv(&tv_tofree);
for (int idx = 0; idx < argcount; ++idx)
clear_tv(&argvars[idx]);
if (error != FCERR_NONE)
{
user_func_error(error, printable_func_name(fp),
funcexe.fe_found_var);
return FAIL;
}
*arg = argp;
return OK;
}
else if (rettv->v_type == VAR_OBJECT)
else if (rettv->v_type == VAR_OBJECT || rettv->v_type == VAR_CLASS)
{
// Search in the object member variable table and the class member
// variable table.
if (get_member_tv(cl, TRUE, name, len, rettv) == OK)
int is_object = rettv->v_type == VAR_OBJECT;
if (get_member_tv(cl, is_object, name, len, rettv) == OK)
{
*arg = name_end;
return OK;
}
if (did_emsg == did_emsg_save)
member_not_found_msg(cl, VAR_OBJECT, name, len);
}
else if (rettv->v_type == VAR_CLASS)
{
int m_idx;
// class member
ocmember_T *m = class_member_lookup(cl, name, len, &m_idx);
if (m == NULL)
{
member_not_found_msg(cl, VAR_CLASS, name, len);
return FAIL;
}
if (*name == '_')
{
emsg_var_cl_define(e_cannot_access_private_variable_str,
m->ocm_name, 0, cl);
return FAIL;
}
typval_T *tv = &cl->class_members_tv[m_idx];
copy_tv(tv, rettv);
class_unref(cl);
*arg = name_end;
return OK;
member_not_found_msg(cl, is_object, name, len);
}
return FAIL;
@@ -2432,24 +2382,12 @@ class_member_lookup(class_T *cl, char_u *name, size_t namelen, int *idx)
return ret_m;
}
/*
* Returns the index of class method "name" in the class "cl".
* Returns -1, if the method is not found.
*/
int
class_method_idx(class_T *cl, char_u *name, size_t namelen)
{
int idx;
class_method_lookup(cl, name, namelen, &idx);
return idx;
}
/*
* Returns a pointer to the class method "name" in class "cl".
* Returns NULL if the method is not found.
* The method index is set in "idx".
*/
ufunc_T *
static ufunc_T *
class_method_lookup(class_T *cl, char_u *name, size_t namelen, int *idx)
{
ufunc_T *ret_fp = NULL;
@@ -2470,12 +2408,24 @@ class_method_lookup(class_T *cl, char_u *name, size_t namelen, int *idx)
return ret_fp;
}
/*
* Returns the index of class method "name" in the class "cl".
* Returns -1, if the method is not found.
*/
int
class_method_idx(class_T *cl, char_u *name, size_t namelen)
{
int idx;
class_method_lookup(cl, name, namelen, &idx);
return idx;
}
/*
* Returns the index of object member variable "name" in the class "cl".
* Returns -1, if the variable is not found.
* If "namelen" is zero, then it is assumed that "name" is NUL terminated.
*/
int
static int
object_member_idx(class_T *cl, char_u *name, size_t namelen)
{
int idx;
@@ -2518,24 +2468,12 @@ object_member_lookup(class_T *cl, char_u *name, size_t namelen, int *idx)
return ret_m;
}
/*
* Returns the index of object method "name" in the class "cl".
* Returns -1, if the method is not found.
*/
int
object_method_idx(class_T *cl, char_u *name, size_t namelen)
{
int idx;
object_method_lookup(cl, name, namelen, &idx);
return idx;
}
/*
* Returns a pointer to the object method "name" in class "cl".
* Returns NULL if the method is not found.
* The object method index is set in "idx".
*/
ufunc_T *
static ufunc_T *
object_method_lookup(class_T *cl, char_u *name, size_t namelen, int *idx)
{
ufunc_T *ret_fp = NULL;
@@ -2558,6 +2496,18 @@ object_method_lookup(class_T *cl, char_u *name, size_t namelen, int *idx)
return ret_fp;
}
/*
* Returns the index of object method "name" in the class "cl".
* Returns -1, if the method is not found.
*/
int
object_method_idx(class_T *cl, char_u *name, size_t namelen)
{
int idx;
object_method_lookup(cl, name, namelen, &idx);
return idx;
}
/*
* Lookup a class or object member variable by name. If v_type is VAR_CLASS,
* then lookup a class member variable and if it is VAR_OBJECT, then lookup a
@@ -2681,42 +2631,6 @@ copy_object(typval_T *from, typval_T *to)
}
}
/*
* Free an object.
*/
static void
object_clear(object_T *obj)
{
// Avoid a recursive call, it can happen if "obj" has a circular reference.
obj->obj_refcount = INT_MAX;
class_T *cl = obj->obj_class;
if (!cl)
return;
// the member values are just after the object structure
typval_T *tv = (typval_T *)(obj + 1);
for (int i = 0; i < cl->class_obj_member_count; ++i)
clear_tv(tv + i);
// Remove from the list headed by "first_object".
object_cleared(obj);
vim_free(obj);
class_unref(cl);
}
/*
* Unreference an object.
*/
void
object_unref(object_T *obj)
{
if (obj != NULL && --obj->obj_refcount <= 0)
object_clear(obj);
}
/*
* Make a copy of a class.
*/
@@ -2866,7 +2780,7 @@ static object_T *next_nonref_obj = NULL;
* Call this function when an object has been cleared and is about to be freed.
* It is removed from the list headed by "first_object".
*/
void
static void
object_cleared(object_T *obj)
{
if (obj->obj_next_used != NULL)
@@ -2881,6 +2795,42 @@ object_cleared(object_T *obj)
next_nonref_obj = obj->obj_next_used;
}
/*
* Free an object.
*/
static void
object_clear(object_T *obj)
{
// Avoid a recursive call, it can happen if "obj" has a circular reference.
obj->obj_refcount = INT_MAX;
class_T *cl = obj->obj_class;
if (!cl)
return;
// the member values are just after the object structure
typval_T *tv = (typval_T *)(obj + 1);
for (int i = 0; i < cl->class_obj_member_count; ++i)
clear_tv(tv + i);
// Remove from the list headed by "first_object".
object_cleared(obj);
vim_free(obj);
class_unref(cl);
}
/*
* Unreference an object.
*/
void
object_unref(object_T *obj)
{
if (obj != NULL && --obj->obj_refcount <= 0)
object_clear(obj);
}
/*
* Go through the list of all objects and free items without "copyID".
*/

View File

@@ -254,7 +254,7 @@ compile_lock_unlock(
{
// Push the class of the bare class variable name
name = cl->class_name;
len = STRLEN(name);
len = (int)STRLEN(name);
#ifdef LOG_LOCKVAR
ch_log(NULL, "LKVAR: ... cctx_class_member: name %s",
name);

View File

@@ -2011,16 +2011,33 @@ compile_lhs(
// for an object or class member get the type of the member
class_T *cl = lhs->lhs_type->tt_class;
int is_object = lhs->lhs_type->tt_type == VAR_OBJECT;
char_u *name = var_start + lhs->lhs_varlen + 1;
size_t namelen = lhs->lhs_end - var_start - lhs->lhs_varlen - 1;
if (!lhs_class_member_modifiable(lhs, var_start, cctx))
ocmember_T *m = member_lookup(cl, lhs->lhs_type->tt_type,
name, namelen, &lhs->lhs_member_idx);
if (m == NULL)
{
member_not_found_msg(cl, lhs->lhs_type->tt_type, name, namelen);
return FAIL;
}
lhs->lhs_member_type = class_member_type(cl,
is_object,
after + 1, lhs->lhs_end,
&lhs->lhs_member_idx);
if (lhs->lhs_member_idx < 0)
// If it is private member variable, then accessing it outside the
// class is not allowed.
// If it is a read only class variable, then it can be modified
// only inside the class where it is defined.
if ((m->ocm_access != VIM_ACCESS_ALL) &&
((is_object && !inside_class(cctx, cl))
|| (!is_object && cctx->ctx_ufunc->uf_class != cl)))
{
char *msg = (m->ocm_access == VIM_ACCESS_PRIVATE)
? e_cannot_access_private_variable_str
: e_variable_is_not_writable_str;
emsg_var_cl_define(msg, m->ocm_name, 0, cl);
return FAIL;
}
lhs->lhs_member_type = m->ocm_type;
}
else
{

View File

@@ -874,8 +874,7 @@ check_type_maybe(
{
where_T func_where = where;
if (where.wt_kind == WT_METHOD)
func_where.wt_kind = WT_METHOD_RETURN;
func_where.wt_kind = WT_METHOD_RETURN;
ret = check_type_maybe(expected->tt_member,
actual->tt_member, FALSE,
func_where);
@@ -898,8 +897,7 @@ check_type_maybe(
&& i < actual->tt_argcount; ++i)
{
where_T func_where = where;
if (where.wt_kind == WT_METHOD)
func_where.wt_kind = WT_METHOD_ARG;
func_where.wt_kind = WT_METHOD_ARG;
// Allow for using "any" argument type, lambda's have them.
if (actual->tt_args[i] != &t_any && check_type(

View File

@@ -136,7 +136,7 @@ extern void perror __P((char *));
# endif
#endif
char version[] = "xxd 2023-10-06 by Juergen Weigert et al.";
char version[] = "xxd 2023-10-08 by Juergen Weigert et al.";
#ifdef WIN32
char osver[] = " (Win32)";
#else
@@ -364,7 +364,7 @@ huntype(
int hextype,
long base_off)
{
int c, ign_garb = 1, n1 = -1, n2 = 0, n3, p = cols, bt, b = 0, bcnt = 0;
int c, ign_garb = 1, n1 = -1, n2 = 0, n3 = 0, p = cols, bt = 0, b = 0, bcnt = 0;
long have_off = 0, want_off = 0;
rewind(fpi);