Skip to content

Commit 4e51ccc

Browse files
committed
release 0.9.20
1 parent efd6d1e commit 4e51ccc

File tree

4 files changed

+154
-5
lines changed

4 files changed

+154
-5
lines changed

CHANGELOG.md

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,81 @@
22

33
[中文Log](CHANGELOG_CN.md)
44

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+
580
# 0.9.19
681

782
`FIX` Fix reading configuration file encoded with UTF-8 BOM
@@ -10,9 +85,9 @@
1085

1186
`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.
1287

13-
`NEW` Support `Goto to implementation`
88+
`NEW` Support `Go to implementation`
1489

15-
`NEW` Support `@nodisacrd` with reason
90+
`NEW` Support `@nodiscard` with reason
1691

1792
`FIX` Fix Some performance issue
1893

CHANGELOG_CN.md

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,79 @@
11
# Change Log
22

3+
# 0.9.20
4+
5+
`FIX` 修复一个崩溃问题
6+
7+
`NEW` 支持函数的`@return_cast`注解。当函数的返回值是布尔值(必须标注为布尔值)时,可以添加额外的注解`---@return_cast <param> <cast op>`,表示当函数返回true时,参数`<param>`将根据转换操作转为相应类型。例如:
8+
```lua
9+
---@return boolean
10+
---@return_cast n integer
11+
local function isInteger(n)
12+
return n == math.floor(n)
13+
end
14+
15+
local a ---@type integer | string
16+
17+
if isInteger(a) then
18+
print(a) -- a: integer
19+
else
20+
print(a) -- a: string
21+
end
22+
```
23+
24+
`@return_cast`支持self参数。例如:
25+
```lua
26+
---@class My2
27+
28+
---@class My1
29+
30+
---@class My3:My2,My1
31+
local m = {}
32+
33+
34+
---@return boolean
35+
---@return_cast self My1
36+
function m:isMy1()
37+
end
38+
39+
---@return boolean
40+
---@return_cast self My2
41+
function m:isMy2()
42+
end
43+
44+
if m:isMy1() then
45+
print(m) -- m: My1
46+
elseif m:isMy2() then
47+
print(m) -- m: My2
48+
end
49+
```
50+
51+
`CHG` 移除诊断`lua-syntax-error`,合并到`syntax-error`中,并添加`doc-syntax-error`用于文档语法错误
52+
53+
`FIX` 修复格式化问题,现在当存在`syntax-error`时,格式化将不返回值
54+
55+
`FIX` 修复性能问题:防止函数返回表时产生大量联合类型
56+
57+
`CHG` 当require函数返回的对象是类/枚举时,禁止在其上定义新成员,而表则不受限制
58+
59+
`NEW` 支持`Lua 5.5`全局声明语法
60+
61+
`NEW` 支持`TypeGuard<T>`作为返回类型。例如:
62+
```lua
63+
64+
---@return TypeGuard<string>
65+
local function is_string(value)
66+
return type(value) == "string"
67+
end
68+
69+
local a
70+
71+
if is_string(a) then
72+
print(a:sub(1, 1))
73+
else
74+
print("a is not a string")
75+
end
76+
```
377

478
# 0.9.19
579

@@ -11,7 +85,7 @@
1185

1286
`NEW` 支持`转到实现`功能
1387

14-
`NEW` 支持 `@nodisacrd` 并可提供原因
88+
`NEW` 支持 `@nodiscard` 并可提供原因
1589

1690
`FIX` 修复一些性能问题
1791

build/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
exports.default = {
22
emmyDebuggerVersion: '1.8.5',
33
emmyDebuggerUrl: 'https://github.com/EmmyLua/EmmyLuaDebugger/releases/download',
4-
newLanguageServerVersion: "0.7.2",
4+
newLanguageServerVersion: "0.7.3",
55
newLanguageServerUrl: "https://github.com/CppCXY/emmylua-analyzer-rust/releases/download"
66
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "emmylua",
33
"displayName": "EmmyLua",
44
"description": "EmmyLua for vscode",
5-
"version": "0.9.19",
5+
"version": "0.9.20",
66
"icon": "res/icon.png",
77
"publisher": "tangzx",
88
"engines": {

0 commit comments

Comments
 (0)