fix: tostring(vim.version()) fails if build is NIL #24097

Problem:
Since #23925, Version.build may be vim.NIL, which causes tostring() to fail:
    E5108: Error executing lua E5114: Error while converting print argument #1: …/version.lua:129:
    attempt to concatenate field 'build' (a userdata value)
    stack traceback:
            [C]: in function 'print'
            [string ":lua"]:1: in main chunk

Solution:
Handle vim.NIL in Version:__tostring().
This commit is contained in:
Julian Grinblat 2023-06-22 16:36:38 +09:00 committed by GitHub
parent 08db61b19b
commit 43e76cc346
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -125,7 +125,7 @@ function Version:__tostring()
if self.prerelease then
ret = ret .. '-' .. self.prerelease
end
if self.build then
if self.build and self.build ~= vim.NIL then
ret = ret .. '+' .. self.build
end
return ret