diff options
| author | Li Jin <dragon-fly@qq.com> | 2024-03-04 11:13:18 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2024-03-04 11:13:18 +0800 |
| commit | 4e9a508a11c16db9aeff44b27e88713ab413bff7 (patch) | |
| tree | 2ef6f1e4904e32379e67b1c35b7bc8031685088a /spec/inputs | |
| parent | 412bc3d7606cb0d07c39861c7ae4e89c7139da31 (diff) | |
| download | yuescript-4e9a508a11c16db9aeff44b27e88713ab413bff7.tar.gz yuescript-4e9a508a11c16db9aeff44b27e88713ab413bff7.tar.bz2 yuescript-4e9a508a11c16db9aeff44b27e88713ab413bff7.zip | |
add default return declaration for function literal.v0.22.2
Diffstat (limited to 'spec/inputs')
| -rw-r--r-- | spec/inputs/funcs.yue | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/inputs/funcs.yue b/spec/inputs/funcs.yue index 0e45ff1..e647edc 100644 --- a/spec/inputs/funcs.yue +++ b/spec/inputs/funcs.yue | |||
| @@ -158,4 +158,39 @@ args = (f,g,m | |||
| 158 | return 1 if n == 0 | 158 | return 1 if n == 0 |
| 159 | n * @(n-1) | 159 | n * @(n-1) |
| 160 | 160 | ||
| 161 | do | ||
| 162 | items.every (item) -> | ||
| 163 | if item.field | ||
| 164 | value = item.field.get "abc" | ||
| 165 | if value | ||
| 166 | switch value\get! | ||
| 167 | when 123 | ||
| 168 | return false | ||
| 169 | when 456 | ||
| 170 | handle item | ||
| 171 | true | ||
| 172 | |||
| 173 | items.every (item): true -> | ||
| 174 | if item.field | ||
| 175 | value = item.field.get "abc" | ||
| 176 | if value | ||
| 177 | switch value\get! | ||
| 178 | when 123 | ||
| 179 | return false | ||
| 180 | when 456 | ||
| 181 | -- prevent implicit return for next line | ||
| 182 | handle item | ||
| 183 | |||
| 184 | HttpServer\post "/login", (req): success: false -> | ||
| 185 | switch req when {:name, :pwd} | ||
| 186 | if name ~= "" | ||
| 187 | if user := DB\queryUser name, pwd | ||
| 188 | if user.status == "available" | ||
| 189 | return success: true | ||
| 190 | |||
| 191 | check = (num) -> return num | ||
| 192 | -- func without implicit return | ||
| 193 | func = (): -> check 123 | ||
| 194 | print func! -- get nil | ||
| 195 | |||
| 161 | nil | 196 | nil |
