|
2 | 2 |
|
3 | 3 | [中文Log](CHANGELOG_CN.md) |
4 | 4 |
|
| 5 | +# 0.9.20 |
| 6 | + |
| 7 | +`FIX` Fix a crash issue |
| 8 | + |
| 9 | +`NEW` Support `@return_cast` for functions. When a function's return value is boolean (must be annotated as boolean), you can add an additional annotation `---@return_cast <param> <cast op>`, indicating that when the function returns true, the parameter `<param>` will be transformed to the corresponding type according to the cast. For example: |
| 10 | +```lua |
| 11 | +---@return boolean |
| 12 | +---@return_cast n integer |
| 13 | +local function isInteger(n) |
| 14 | + return n == math.floor(n) |
| 15 | +end |
| 16 | + |
| 17 | +local a ---@type integer | string |
| 18 | + |
| 19 | +if isInteger(a) then |
| 20 | + print(a) -- a: integer |
| 21 | +else |
| 22 | + print(a) -- a: string |
| 23 | +end |
| 24 | +``` |
| 25 | + |
| 26 | +`@return_cast` support self param. For example: |
| 27 | +```lua |
| 28 | +---@class My2 |
| 29 | + |
| 30 | +---@class My1 |
| 31 | + |
| 32 | +---@class My3:My2,My1 |
| 33 | +local m = {} |
| 34 | + |
| 35 | + |
| 36 | +---@return boolean |
| 37 | +---@return_cast self My1 |
| 38 | +function m:isMy1() |
| 39 | +end |
| 40 | + |
| 41 | +---@return boolean |
| 42 | +---@return_cast self My2 |
| 43 | +function m:isMy2() |
| 44 | +end |
| 45 | + |
| 46 | +if m:isMy1() then |
| 47 | + print(m) -- m: My1 |
| 48 | +elseif m:isMy2() then |
| 49 | + print(m) -- m: My2 |
| 50 | +end |
| 51 | +``` |
| 52 | + |
| 53 | +`CHG` Remove diagnostic `lua-syntax-error`, it merges into `syntax-error`, add `doc-syntax-error` for doc syntax error |
| 54 | + |
| 55 | +`FIX` Fix format issue, Now When exist `syntax-error`, the format never return value |
| 56 | + |
| 57 | +`FIX` Fix a performance issue: prevent large union types when functions return tables |
| 58 | + |
| 59 | +`CHG` When an object returned by require function is a class/enum, defining new members on it is prohibited, while tables are not restricted |
| 60 | + |
| 61 | +`NEW` Support `Lua 5.5` global decl grammar |
| 62 | + |
| 63 | +`NEW` Support `TypeGuard<T>` as return type. For example: |
| 64 | +```lua |
| 65 | + |
| 66 | +---@return TypeGuard<string> |
| 67 | +local function is_string(value) |
| 68 | + return type(value) == "string" |
| 69 | +end |
| 70 | + |
| 71 | +local a |
| 72 | + |
| 73 | +if is_string(a) then |
| 74 | + print(a:sub(1, 1)) |
| 75 | +else |
| 76 | + print("a is not a string") |
| 77 | +end |
| 78 | +``` |
| 79 | + |
5 | 80 | # 0.9.19 |
6 | 81 |
|
7 | 82 | `FIX` Fix reading configuration file encoded with UTF-8 BOM |
|
10 | 85 |
|
11 | 86 | `NEW` Support new tag `@internal` for members or declarations. When a member or declaration is marked as `@internal`, it is only visible within its current library. This means that if you use `@internal` in one library, you cannot access this member or declaration from other libraries or workspace. |
12 | 87 |
|
13 | | -`NEW` Support `Goto to implementation` |
| 88 | +`NEW` Support `Go to implementation` |
14 | 89 |
|
15 | | -`NEW` Support `@nodisacrd` with reason |
| 90 | +`NEW` Support `@nodiscard` with reason |
16 | 91 |
|
17 | 92 | `FIX` Fix Some performance issue |
18 | 93 |
|
|
0 commit comments