Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

gleam / CHANGELOG.md
12 kB 477 lines
1<!-- 2 SPDX-License-Identifier: Apache-2.0 3 SPDX-FileCopyrightText: 2020 The Gleam contributors 4--> 5 6# Changelog 7 8## Unreleased 9 10### Compiler 11 12- The compiler now issues a friendlier error when attempting to pattern match 13 on both the prefix and suffix of a string: 14 15 ``` 16 error: Syntax error 17 ┌─ /src/parse/error.gleam:2:23 18 19 2 │ "prefix" <> infix <> "suffix" -> infix 20 │ ^^^^^^^^^^^ This pattern is not allowed 21 22 A string pattern can only match on a literal string prefix. 23 24 Matching on a literal suffix is not possible, because `infix` would have an 25 unknown size. 26 ``` 27 28 ([Gavin Morrow](https://github.com/gavinmorrow)) 29 30- Improved the error message shown when using an invalid discard name for 31 functions, constants, module names, and `as` patterns. 32 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 33 34- The compiler now generates singleton values for variants with no fields on the 35 JavaScript target, allowing for faster comparison in most cases. 36 ([Surya Rose](https://github.com/GearsDatapacks)) 37 38- The use of pipes to turn the Gleam code `a |> b(c)` into `b(c)(a)` has been 39 deprecated. 40 ([Surya Rose](https://github.com/GearsDatapacks)) 41 42- The compiler now gives a better error message when an `@external` 43 attribute is incomplete. For example: 44 45 ```gleam 46 @external 47 pub fn wibble() 48 ``` 49 50 now points to the attribute itself and explains that it is incomplete. 51 ([Asish Kumar](https://github.com/officialasishkumar)) 52 53### Build tool 54 55- The build tool now generates Hexdocs URLs using the new format of 56 `package.hexdocs.pm` rather than `hexdocs.pm/package`. 57 ([Surya Rose](https://github.com/GearsDatapacks)) 58 59- More readable error message when trying to revert an old release. 60 ([Moritz Böhme](https://github.com/MoritzBoehme)) 61 62- The build tool now includes destination path in the error when it fails to 63 link or copy file or directory. 64 ([Andrey Kozhev](https://github.com/ankddev)) 65 66- Git dependencies now support an optional `path` field to specify a 67 subdirectory within the repository. This is useful for monorepos that 68 contain multiple Gleam packages. For example: 69 70 ```toml 71 [dependencies] 72 my_package = { git = "https://github.com/example/monorepo", ref = "main", path = "packages/my_package" } 73 ``` 74 75 ([John Downey](https://github.com/jtdowney)) 76 77### Language server 78 79- The language server now supports go-to-definition, find-references and rename 80 for record fields. These work on the field declaration, on labelled arguments, 81 on labelled patterns, on record updates and on `record.field` accesses, both 82 within a module and across modules. For example: 83 84 ```gleam 85 pub type Person { 86 Person(name: String, age: Int) 87 } 88 89 pub fn main() { 90 let lucy = Person(name: "Lucy", age: 10) 91 lucy.name 92 // ^ Go-to-definition jumps to the `name` field, and renaming it here 93 // renames the field everywhere it is used. 94 } 95 ``` 96 97 ([Alistair Smith](https://github.com/alii)) 98 99- The "pattern match on value" code action can now be used to pattern match on 100 values returned by function calls. For example: 101 102 ```gleam 103 pub fn main() { 104 load_user() 105 // ^^ Triggering the code action over here 106 } 107 108 fn load_user() -> Result(User, Nil) { todo } 109 ``` 110 111 Will produce the following code: 112 113 ```gleam 114 pub fn main() { 115 case load_user() { 116 Ok(value) -> todo 117 Error(value) -> todo 118 } 119 } 120 ``` 121 122 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 123 124- The "remove unreachable patterns" code action can now be triggered on 125 unreachable alternative patterns of a case expression. 126 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 127 128- The language server now permits renaming type variables in functions, types, 129 and constants. For example: 130 131 ```gleam 132 pub fn twice(value: a, f: fn(a) -> a) -> a { 133 // ^ Rename to "anything" 134 f(f(value)) 135 } 136 ``` 137 138 Produces: 139 140 ```gleam 141 pub fn twice(value: anything, f: fn(anything) -> anything) -> anything { 142 f(f(value)) 143 } 144 ``` 145 146 ([Surya Rose](https://github.com/GearsDatapacks)) 147 148- The language server now automatically updates imports when a Gleam module is 149 renamed. For example: 150 151 ```gleam 152 import db_users 153 154 pub fn main() -> db_users.User { 155 db_users.new("username") 156 } 157 ``` 158 159 Renaming `db_users.gleam` to `database/user.gleam` would produce: 160 161 ```gleam 162 import database/user 163 164 pub fn main() -> user.User { 165 user.new("username") 166 } 167 ``` 168 169 ([Surya Rose](https://github.com/GearsDatapacks)) 170 171- The language server now offers a code action to generate a missing type 172 definition when an unknown type is referenced. For example, if `Wibble` 173 is not defined: 174 175 ```gleam 176 pub fn run(data: Wibble(Int)) { todo } 177 ``` 178 179 The code action will generate: 180 181 ```gleam 182 pub type Wibble(a) 183 184 pub fn run(data: Wibble(Int)) { todo } 185 ``` 186 187 ([Daniele Scaratti](https://github.com/lupodevelop)) 188 189- The language server now has "Discard unused variable" code action to discard 190 unused variables in different places. For example, 191 192 ```gleam 193 pub type Wibble { 194 Wibble(a: Int) 195 } 196 197 pub fn go(record: Wibble) -> Nil { 198 let wibble = 0 199 // ^ Trigger code action here 200 201 case record { 202 Wibble(a:) -> Nil 203 // ^ Trigger code action here 204 } 205 206 case [0, 1, 2] { 207 [_, ..] as wobble -> Nil 208 // ^ Trigger code action here 209 [] -> Nil 210 } 211 212 Nil 213 } 214 ``` 215 216 Triggering the code action in all of these places would produce following code: 217 218 ```gleam 219 pub type Wibble { 220 Wibble(a: Int) 221 } 222 223 pub fn go(record: Wibble) -> Nil { 224 let _wibble = 0 225 226 case record { 227 Wibble(a: _) -> Nil 228 } 229 230 case [0, 1, 2] { 231 [_, ..] -> Nil 232 [] -> Nil 233 } 234 235 Nil 236 } 237 ``` 238 239 ([Andrey Kozhev](https://github.com/ankddev)) 240 241- The language server will now better rename types and values with import 242 aliases by removing `as ...` part in case new name is same as original name of 243 item. For example: 244 245 ```gleam 246 import wibble.{type Wibble as Wobble, Wibble as Wobble} 247 248 pub fn go() -> Wobble { 249 // ^^^^^^ Rename to `Wibble` 250 Wobble 251 //^^^^^^ Rename to `Wibble` 252 } 253 ``` 254 255 Will now result in this code: 256 257 ```gleam 258 import wibble.{type Wibble, Wibble} 259 260 pub fn go() -> Wibble { 261 Wibble 262 } 263 ``` 264 265 ([Andrey Kozhev](https://github.com/ankddev)) 266 267- The language server now supports folding of comments and documentation 268 comments. For example, this code: 269 270 ```gleam 271 //// Very useful module. 272 //// 273 //// It could be used to make interesting things 274 275 /// Function to wibble. 276 /// 277 /// Not that it wobbles when wubble is true 278 pub fn wibble() { 279 // This todo here is temporary. 280 // It will need to be removed at some moment. 281 todo 282 } 283 ``` 284 285 can now be folded to: 286 287 ```gleam 288 //// Very useful module. ... 289 290 /// Function to wibble. ... 291 pub fn wibble() { 292 // This todo here is temporary. ... 293 todo 294 } 295 ``` 296 297 ([Andrey Kozhev](https://github.com/ankddev)) 298 299- The "Convert to function call" code action will now convert the currently 300 hovered call and not only the final one. 301 ([Andrey Kozhev](https://github.com/ankddev)) 302 303- When using the "Extract function" code action on statements whose values are 304 unused, the extracted function will return the last statement. For example: 305 306 ```gleam 307 fn main() { 308 //↓ start selection here 309 echo "line 2" 310 echo "line 3" 311 // ↑ end selection here 312 echo "line 4" 313 } 314 ``` 315 316 will be turned into 317 318 ```gleam 319 fn main() { 320 function() 321 echo "line 4" 322 } 323 324 fn function() -> String { 325 echo "line 2" 326 echo "line 3" 327 } 328 ``` 329 330 ([Gavin Morrow](https://github.com/gavinmorrow)) 331 332- The language server now offers a code action to fix the new deprecated pipeline 333 syntax. 334 ([Surya Rose](https://github.com/GearsDatapacks)) 335 336### Formatter 337 338- Performance of the formatter has been improved. 339 `gleam format` has been measured to be up to 13% faster on projects like 340 `lustre`, with a 10% smaller peak memory footprint. 341 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 342 343- Formatter now removes import aliases if the aliased name is the 344 same as the original name. For example, 345 346 ```gleam 347 import wibble.{Wibble as Wibble} 348 ``` 349 350 becomes 351 352 ```gleam 353 import wibble.{Wibble} 354 ``` 355 356 ([Daniel Venable](https://github.com/DanielVenable)) 357 358### Bug fixes 359 360- When using the language server to extract a function from within an anonymous 361 function, the return value of the extracted function is respected. 362 363 For example, 364 365 ```gleam 366 fn wibble() { 367 let wobble = fn() { 368 let random_number = 4 369 random_number * 42 // <- Extracting this line 370 } 371 } 372 ``` 373 374 is turned into 375 376 ```gleam 377 fn wibble() { 378 let wobble = fn() { 379 let random_number = 4 380 function(random_number) 381 } 382 } 383 fn function(random_number: Int) -> Int { 384 random_number * 42 385 } 386 ``` 387 388 ([Gavin Morrow](https://github.com/gavinmorrow)) 389 390- Work around an ambiguity of the language server protocol that resulted in 391 editors like Zed inserting the wrong text when accepting type completions. 392 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 393 394- Fixed a bug where the post-publish message for pushing a git commit was 395 formatted incorrectly. 396 ([Louis Pilfold](https://github.com/lpil)) 397 398- Fixed a bug where the compiler would generate invalid TypeScript type 399 definitions for records with a field named `constructor`. 400 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 401 402- Fixed a bug where the compiler would raise a warning for truncated int 403 segments when compiling a function with a JavaScript external. 404 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 405 406- A `gleam@@compile.erl` is no longer left in the build output of 407 `gleam compile-package`. 408 ([Louis Pilfold](https://github.com/lpil)) 409 410- When using the language server to extract a function from within the body of a 411 use statement, only the selected statement(s) are extracted. 412 413 For example, 414 415 ```gleam 416 pub fn wibble() { 417 use wobble <- result.map(todo) 418 echo wobble as "1" // <- Extracting this line 419 echo wobble as "2" 420 } 421 ``` 422 423 is turned into 424 425 ```gleam 426 pub fn wibble() { 427 use wobble <- result.map(todo) 428 function(wobble) 429 echo wobble as "2" 430 } 431 fn function(wobble: a) -> a { 432 echo wobble as "1" 433 } 434 ``` 435 436 ([Gavin Morrow](https://github.com/gavinmorrow)) 437 438- Fixed a bug where the JavaScript code generator could produce duplicate `let` 439 declarations when a variable was reassigned after being shadowed inside a 440 directly matching `case` branch. 441 ([Eyup Can Akman](https://github.com/eyupcanakman)) 442 443- Fixed a bug where the language server would produce wrong code when triggering 444 rename of types and values with import aliases. 445 ([Andrey Kozhev](https://github.com/ankddev)) 446 447- Fixed a bug where referencing qualified constructors in constant where a value 448 of the same name exists in scope would cause invalid code to be generated. 449 ([Surya Rose](https://github.com/GearsDatapacks)) 450 451- Fixed a bug that would result in `gleam build` being slower than necessary 452 when finding the Gleam files of a package. 453 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 454 455- The formatter now properly formats binary operations in bit array size 456 segments. 457 ([Andrey Kozhev](https://github.com/ankddev)) 458 459- Fixed a bug where after removing dependencies with `gleam remove` if a 460 removed dependency is still used the build would succeed, resulting in 461 runtime crash due to missing files. 462 ([Andrey Kozhev](https://github.com/ankddev)) 463 464- The build tool will no longer panic when unable to lock the build directory. 465 ([Louis Pilfold](https://github.com/lpil)) 466 467- The formatter now properly indents multiline trailing comments inside of 468 multiline lists and tuples. 469 ([0xda157](https://github.com/0xda157)) 470 471- Fixed a bug where the compiler would panic on the first HTTPS request on 472 Android. 473 ([John Downey](https://github.com/jtdowney)) 474 475- Fixed a bug where the language server would not show autocomplete for record 476 fields of internal types within the same package. 477 ([Surya Rose](https://github.com/GearsDatapacks))