ldoc icon indicating copy to clipboard operation
ldoc copied to clipboard

function with inline return and errors won't work

Open ziras opened this issue 7 years ago • 1 comments
trafficstars

function with inline return and errors won't work

In the screenshot above we can see that the doc generated by LDoc 1.4.6 to the right only has the name param. However @error[1], @error[2] and @treturn aren't working.

Steps to replicate:

$ cat multiple.lua 
------
-- Various ways of indicating errors
-- @module multiple

----
-- function with inline return and errors
-- @string name
function mul4 (name)
    if type(name) ~= 'string' then
        --- @error[1] not a string
        return nil, 'not a string'
    end
    if #name == 0 then
        --- @error[2] zero-length string
        return nil, 'zero-length string'
    end
    --- @treturn string converted to uppercase
    return name:upper()
end
$ ldoc multiple.lua 
/private/tmp/ldoc/multiple.lua:11: definition cannot be parsed - not returning function or table
/private/tmp/ldoc/multiple.lua:11: definition cannot be parsed - not returning function or table
/private/tmp/ldoc/multiple.lua:15: definition cannot be parsed - not returning function or table
/private/tmp/ldoc/multiple.lua:15: definition cannot be parsed - not returning function or table
/private/tmp/ldoc/multiple.lua:18: definition cannot be parsed - not returning function or table
/private/tmp/ldoc/multiple.lua:18: definition cannot be parsed - not returning function or table
output written to /private/tmp/ldoc/doc

ziras avatar Dec 29 '17 05:12 ziras

+1

MasterVitronic avatar Mar 28 '20 18:03 MasterVitronic