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

Configure Feed

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

Reset changelog

+554 -541
+1 -541
CHANGELOG.md
··· 1 1 # Changelog 2 2 3 - ## v1.10.0 - 2025-04-14 4 - 5 - ### Bug fixes 6 - 7 - - Fixed a bug where the code action to unqualify types and values would add an 8 - unqualified import even if it was already imported. 9 - ([Surya Rose](https://github.com/GearsDatapacks)) 10 - 11 - - Fixed a bug where numbers starting with `0x_`, `0o_` and `0b_` would cause 12 - a syntax error when compiling to JavaScript. 13 - ([Surya Rose](https://github.com/GearsDatapacks)) 14 - 15 - ## v1.10.0-rc1 - 2025-04-05 3 + ## Unreleased 16 4 17 5 ### Compiler 18 6 19 - - On the JavaScript target, bit arrays can now use the `unit` option to control 20 - the units of the `size` option. 21 - ([Surya Rose](https://github.com/GearsDatapacks)) 22 - 23 - - The compiler can now tell if string branches are unreachable. For example, the 24 - following code: 25 - 26 - ```gleam 27 - case a_string { 28 - "Hello, " <> name -> name 29 - "Hello, Jak" -> "Jak" 30 - _ -> "Stranger" 31 - } 32 - ``` 33 - 34 - Will raise the following warning: 35 - 36 - ``` 37 - warning: Unreachable case clause 38 - ┌─ /src/greet.gleam:7:5 39 - 40 - 7 │ "Hello, Jak" -> "Jak" 41 - │ ^^^^^^^^^^^^^^^^^^^^^ 42 - 43 - This case clause cannot be reached as a previous clause matches the same 44 - values. 45 - 46 - Hint: It can be safely removed. 47 - ``` 48 - 49 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 50 - 51 - - On the JavaScript target, blocks and various other expressions no longer 52 - compile to immediately invoked function expressions. 53 - ([Surya Rose](https://github.com/GearsDatapacks)) 54 - 55 - - On the JavaScript target, bit arrays can now use 16-bit floats in expressions 56 - and patterns. 57 - ([Richard Viney](https://github.com/richard-viney)) 58 - 59 - - Improved the error message for unknown and missing target names in the 60 - `@target` attribute. 61 - ([Alexander Keleschovsky](https://github.com/AlecGhost)) 62 - 63 - - The compiler now uses a call graph for detecting unused types and values. 64 - This means that among other things, it can now detect unused recursive 65 - functions. For example: 66 - 67 - ```gleam 68 - // warning: unused 69 - fn some_recursive_function() { 70 - some_recursive_function() 71 - } 72 - ``` 73 - 74 - ([Surya Rose](https://github.com/GearsDatapacks)) 75 - 76 - - The compiler now emits a warning when using `let assert` to assert a value 77 - whose variant has already been inferred. For example: 78 - 79 - ```gleam 80 - // warning: This will always crash 81 - let assert Ok(_) = Error("Some error") 82 - ``` 83 - 84 - ([Surya Rose](https://github.com/GearsDatapacks)) 85 - 86 - - It is now possible to omit the `:float` option for literal floats used in a 87 - `BitArray` segment. 88 - 89 - ```gleam 90 - <<1.11>> 91 - ``` 92 - 93 - Is the same as: 94 - 95 - ```gleam 96 - <<1.11:float>> 97 - ``` 98 - 99 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 100 - 101 - - Compilation of binary operators is now fault tolerant and won't stop at the 102 - first type error. 103 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 104 - 105 - - The compiler now provides a better error message when using the wrong operator 106 - to try and join two strings together. For example: 107 - 108 - ```txt 109 - error: Type mismatch 110 - ┌─ /src/wibble.gleam:2:13 111 - 112 - 2 │ "Hello, " + "Lucy" 113 - │ ^ Use <> instead 114 - 115 - The + operator can only be used on Ints. 116 - To join two strings together you can use the <> operator. 117 - ``` 118 - 119 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 120 - 121 - - The compiler now provides a better error message when using an Int operator on 122 - Float values, suggesting the correct replacement. For example: 123 - 124 - ```txt 125 - error: Type mismatch 126 - ┌─ /Users/giacomocavalieri/Desktop/prova/src/prova.gleam:2:7 127 - 128 - 2 │ 1.0 + 2.0 129 - │ ^ Use +. instead 130 - 131 - The + operator can only be used on Ints. 132 - ``` 133 - 134 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 135 - 136 - - The compiler now provides a better error message when using a Float operator 137 - on Int values, suggesting the correct replacement. For example: 138 - 139 - ```txt 140 - error: Type mismatch 141 - ┌─ /Users/giacomocavalieri/Desktop/prova/src/prova.gleam:2:5 142 - 143 - 2 │ 1 >. 2 144 - │ ^^ Use > instead 145 - 146 - The >. operator can only be used on Floats. 147 - ``` 148 - 149 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 150 - 151 - - The compiler no longer shows errors for a function's labels if the called 152 - function itself doesn't exist. 153 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 154 - 155 7 ### Build tool 156 8 157 - - Include a type annotation for the `main` function generated by `gleam new`. 158 - ([Drew Olson](https://github.com/drewolson)) 159 - 160 - - Two entry point scripts are now always generated by `gleam export erlang-shipment`: 161 - 162 - - `entrypoint.sh` for POSIX Shell 163 - - `entrypoint.ps1` for PowerShell 164 - 165 - ([Greg Burri](https://github.com/ummon)) 166 - 167 - - The `gleam export` command now takes a `package-information` option to 168 - export the project's `gleam.toml` as a JSON file. 169 - ([Rodrigo Álvarez](https://github.com/Papipo)) 170 - 171 - - Improved the error message when failing to encrypt or decrypt a local 172 - Hex API key. 173 - ([Samuel Cristobal](https://github.com/scristobal)) 174 - 175 - - The `HEXPM_USER` and `HEXPM_PASS` environment variables when running 176 - `gleam publish` have been deprecated in favour of `HEXPM_API_KEY`. 177 - ([Samuel Cristobal](https://github.com/scristobal)) 178 - 179 - - The "functions" and "constants" sections of generated HTML documentation have 180 - been merged into one "values" section. 181 - ([Sam Zanca](https://github.com/metruzanca)) 182 - 183 9 ### Language server 184 10 185 - - The language server now allows renaming of functions, constants, 186 - custom type variants and custom types across modules. For example: 187 - 188 - ```gleam 189 - // wibble.gleam 190 - pub fn wibble() { 191 - wibble() 192 - //^ Trigger rename 193 - } 194 - // wobble.gleam 195 - import wibble 196 - 197 - pub fn main() { 198 - wibble.wibble() 199 - } 200 - ``` 201 - 202 - Becomes: 203 - 204 - ```gleam 205 - // wibble.gleam 206 - pub fn wobble() { 207 - wobble() 208 - } 209 - // wobble.gleam 210 - import wibble 211 - 212 - pub fn main() { 213 - wibble.wobble() 214 - } 215 - ``` 216 - 217 - ([Surya Rose](https://github.com/GearsDatapacks)) 218 - 219 - - The language server can now offer a code action to replace a `..` in a pattern 220 - with all the fields that are being ignored. For example triggering the code 221 - action on this spread: 222 - 223 - ```gleam 224 - pub type Pokemon { 225 - Pokemon(id: Int, name: String, moves: List(String)) 226 - } 227 - 228 - pub fn main() { 229 - let Pokemon(..) = todo 230 - // ^ If you put your cursor here 231 - } 232 - ``` 233 - 234 - Would generate the following code: 235 - 236 - ```gleam 237 - pub type Pokemon { 238 - Pokemon(id: Int, name: String, moves: List(String)) 239 - } 240 - 241 - pub fn main() { 242 - let Pokemon(id:, name:, moves:) = todo 243 - } 244 - ``` 245 - 246 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 247 - 248 - - The function generated by the "Generate JSON encoder" code action has been 249 - slightly modified so that it will now fail to compile if the type has new 250 - fields added, ensuring the programmer remembers to re-run the code action. 251 - For example, for this type: 252 - 253 - ```gleam 254 - type Person { 255 - Person(name: String, age: Int) 256 - } 257 - ``` 258 - 259 - The following code used to be generated: 260 - 261 - ```gleam 262 - fn encode_person(person: Person) -> json.Json { 263 - json.object([ 264 - #("name", json.string(person.name)), 265 - #("age", json.int(person.age)), 266 - ]) 267 - } 268 - ``` 269 - 270 - But now, this code is generated: 271 - 272 - ```gleam 273 - fn encode_person(person: Person) -> json.Json { 274 - let Person(name:, age:) = person 275 - json.object([ 276 - #("name", json.string(name)), 277 - #("age", json.int(age)), 278 - ]) 279 - } 280 - ``` 281 - 282 - ([Surya Rose](https://github.com/GearsDatapacks)) 283 - 284 - - The language server now supports finding references to values and types, 285 - both within a module and across multiple modules. 286 - ([Surya Rose](https://github.com/GearsDatapacks)) 287 - 288 - - The language server now offers a code action to remove all `echo`s in a 289 - module. For example: 290 - 291 - ```gleam 292 - pub fn main() { 293 - [1, 2, 3] 294 - |> echo 295 - // ^^^^ If you put your cursor over here 296 - |> list.filter(int.is_even) 297 - |> echo 298 - } 299 - ``` 300 - 301 - Triggering the code action would remove all the `echo` pipeline steps: 302 - 303 - ```gleam 304 - pub fn main() { 305 - [1, 2, 3] 306 - |> list.filter(int.is_even) 307 - } 308 - ``` 309 - 310 - This also works with all the `echo`s used before an expression: 311 - 312 - ```gleam 313 - pub fn main() { 314 - echo 1 + 2 315 - //^^^^^^^^^^ If hovering anywhere over here 316 - } 317 - ``` 318 - 319 - Triggering the code action would remove the `echo`: 320 - 321 - ```gleam 322 - pub fn main() { 323 - 1 + 2 324 - } 325 - ``` 326 - 327 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 328 - 329 - - The language server now offers a code action to replace a Float operator used 330 - on Int values with the correct operator. For example: 331 - 332 - ```gleam 333 - pub fn main() { 334 - 11 +. 1 335 - //^^^^^^^ When hovering anywhere over here 336 - } 337 - ``` 338 - 339 - Triggering the code action would fix the compilation error by using the 340 - correct Int operator: 341 - 342 - ```gleam 343 - pub fn main() { 344 - 11 + 1 345 - } 346 - ``` 347 - 348 - This also works the other way around: 349 - 350 - ```gleam 351 - pub fn main() { 352 - 1.1 + 10.0 353 - //^^^^^^^^^^ If hovering anywhere over here 354 - } 355 - ``` 356 - 357 - Triggering the code action would replace the wrong operator with the correct 358 - equivalent Float operator: 359 - 360 - ```gleam 361 - pub fn main() { 362 - 1.1 +. 10.0 363 - } 364 - ``` 365 - 366 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 367 - 368 - - If there's a compilation error because two strings are being joined with the 369 - wrong `+` operator (instead of using `<>`), the language server now offers a 370 - code action to fix the error automatically. For example: 371 - 372 - ```gleam 373 - pub fn main() { 374 - "Hello, " + "Jak" 375 - //^^^^^^^^^^^^^^^^^ When hovering anywhere over here 376 - } 377 - ``` 378 - 379 - Triggering the code action would fix the compilation error by using the 380 - correct `<>` operator instead of `+`: 381 - 382 - ```gleam 383 - pub fn main() { 384 - "Hello, " <> "Jak" 385 - } 386 - ``` 387 - 388 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 389 - 390 - - The language server now offers the option to lift expressions into consts. 391 - For example, in two uses of the code action: 392 - 393 - ```gleam 394 - pub fn main() { 395 - [#("a", 0), #("b", 1), #("a", 2)] 396 - |> key_filter("a") 397 - } 398 - ``` 399 - 400 - Becomes: 401 - 402 - ```gleam 403 - const values = [#("a", 0), #("b", 1), #("a", 2)] 404 - 405 - const string = "a" 406 - 407 - pub fn main() { 408 - values 409 - |> key_filter(string) 410 - } 411 - ``` 412 - 413 - ([Matias Carlander](https://github.com/matiascr)) 414 - 415 - - The language server will now only offer the code action to generate a JSON 416 - encoder if the `gleam_json` package is installed as a dependency. 417 - ([Surya Rose](https://github.com/GearsDatapacks)) 418 - 419 - - The language server will offer to wrap assignment or case clause values in 420 - blocks. Useful when adding more expressions to an existing case clause or 421 - variable assignment. 422 - 423 - ```gleam 424 - pub fn f(pokemon_type: PokemonType) { 425 - case pokemon_type { 426 - Water -> soak() 427 - // ^^^^^^ selecting the right-hand side of the `->` in a clause 428 - Fire -> burn() 429 - } 430 - } 431 - ``` 432 - 433 - Becomes 434 - 435 - ```gleam 436 - pub fn f(pokemon_type: PokemonType) { 437 - case pokemon_type { 438 - Water -> { 439 - soak() 440 - } 441 - Fire -> burn() 442 - } 443 - } 444 - ``` 445 - 446 - ([Matias Carlander](https://github.com/matiascr)) 447 - 448 - - The "Generate function" code action now uses labels or variable names to improve 449 - the names of generated arguments. For example: 450 - 451 - ```gleam 452 - pub fn main() { 453 - let language = English 454 - greet(language, name: "Louis") 455 - } 456 - ``` 457 - 458 - Will generate the following function: 459 - 460 - ```gleam 461 - pub fn greet(language: String, name name: String) -> a { 462 - todo 463 - } 464 - ``` 465 - 466 - ([Surya Rose](https://github.com/GearsDatapacks)) 467 - 468 - - The "Rewrite from `use`" code action now only triggers if the cursor is on the 469 - first line of the `use` expression to rewrite. 470 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 471 - 472 11 ### Formatter 473 12 474 - ### Container images 475 - 476 - - Container images now contain Software Bill of Materials (SBoM) and SLSA 477 - Provenance information. 478 - ([Jonatan Männchen](https://github.com/maennchen)) 479 - 480 13 ### Bug fixes 481 - 482 - - Fixed a bug where tuples with atoms in the first position could be 483 - incorrectly formatted by `echo`. 484 - ([Louis Pilfold](https://github.com/lpil)) 485 - 486 - - Fixed a bug where unlabelled arguments would be allowed after labelled 487 - arguments in variant constructor definitions. 488 - ([Surya Rose](https://github.com/GearsDatapacks)) 489 - 490 - - Fixed a bug where using the "Convert to pipe" code action on a function whose 491 - first argument is itself a pipe would result in invalid code. 492 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 493 - 494 - - Fixed a bug where using the "Convert to pipe" code action on a function or 495 - record capture produces invalid code. 496 - ([Matias Carlander](https://github.com/matiascr)) 497 - 498 - - Fixed a bug where a temporarily moved or removed file does not get recompiled, 499 - even though its dependencies changed in the meanwhile. 500 - ([Sakari Bergen](http://github.com/sbergen)) 501 - 502 - - Fixed a bug where the "Inline variable" code action would not work properly 503 - if used inside a record update. 504 - ([Surya Rose](https://github.com/GearsDatapacks)) 505 - 506 - - Fixed a bug where variant inference wouldn't work on `let assert` assignments. 507 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 508 - 509 - - Fixed a bug where the build tool could fail to lock the build directory but 510 - not report an error. 511 - ([Louis Pilfold](https://github.com/lpil)) 512 - 513 - - Fixed a bug where the language server would be too eager to recompile modules 514 - when it could use the cache from previous compilations. 515 - ([Louis Pilfold](https://github.com/lpil)) 516 - 517 - - Fixed a bug where `let assert` would not assert that the given value matched 518 - the pattern if it was the only expression inside a block. 519 - ([Surya Rose](https://github.com/GearsDatapacks)) 520 - 521 - - Fixed a bug where the code generated for `echo` on JavaScript could have name 522 - collisions if there are functions called `console` or `process`, or custom type 523 - variants called `Object` or `Deno` defined in the module. 524 - ([Louis Pilfold](https://github.com/lpil)) 525 - 526 - - Fixed a bug where the language server would stop working if the build 527 - directory was deleted e.g. as a result of `gleam clean`. 528 - ([Sakari Bergen](https://github.com/sbergen)) 529 - 530 - - Fixed a bug where the "Rewrite to pipe" code action could generate invalid 531 - code when the piped argument was a binary operation. 532 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 533 - 534 - - Fixed a bug where prelude types and values would be suggested in autocomplete 535 - when part of a module select. 536 - ([Surya Rose](https://github.com/GearsDatapacks)) 537 - 538 - - Fixed a bug where the check for multiple top-level modules when publishing 539 - would incorrectly print a warning. 540 - ([Surya Rose](https://github.com/GearsDatapacks)) 541 - 542 - ## v1.9.1 - 2025-03-10 543 - 544 - ### Formatter 545 - 546 - - Improved the formatting of pipelines printed with `echo`. 547 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 548 - 549 - ### Bug fixes 550 - 551 - - Fixed a bug where `echo` used before a pipeline would generate invalid code 552 - for the Erlang target. 553 - ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
+553
changelog/v1.10.md
··· 1 + # Changelog 2 + 3 + ## v1.10.0 - 2025-04-14 4 + 5 + ### Bug fixes 6 + 7 + - Fixed a bug where the code action to unqualify types and values would add an 8 + unqualified import even if it was already imported. 9 + ([Surya Rose](https://github.com/GearsDatapacks)) 10 + 11 + - Fixed a bug where numbers starting with `0x_`, `0o_` and `0b_` would cause 12 + a syntax error when compiling to JavaScript. 13 + ([Surya Rose](https://github.com/GearsDatapacks)) 14 + 15 + ## v1.10.0-rc1 - 2025-04-05 16 + 17 + ### Compiler 18 + 19 + - On the JavaScript target, bit arrays can now use the `unit` option to control 20 + the units of the `size` option. 21 + ([Surya Rose](https://github.com/GearsDatapacks)) 22 + 23 + - The compiler can now tell if string branches are unreachable. For example, the 24 + following code: 25 + 26 + ```gleam 27 + case a_string { 28 + "Hello, " <> name -> name 29 + "Hello, Jak" -> "Jak" 30 + _ -> "Stranger" 31 + } 32 + ``` 33 + 34 + Will raise the following warning: 35 + 36 + ``` 37 + warning: Unreachable case clause 38 + ┌─ /src/greet.gleam:7:5 39 + 40 + 7 │ "Hello, Jak" -> "Jak" 41 + │ ^^^^^^^^^^^^^^^^^^^^^ 42 + 43 + This case clause cannot be reached as a previous clause matches the same 44 + values. 45 + 46 + Hint: It can be safely removed. 47 + ``` 48 + 49 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 50 + 51 + - On the JavaScript target, blocks and various other expressions no longer 52 + compile to immediately invoked function expressions. 53 + ([Surya Rose](https://github.com/GearsDatapacks)) 54 + 55 + - On the JavaScript target, bit arrays can now use 16-bit floats in expressions 56 + and patterns. 57 + ([Richard Viney](https://github.com/richard-viney)) 58 + 59 + - Improved the error message for unknown and missing target names in the 60 + `@target` attribute. 61 + ([Alexander Keleschovsky](https://github.com/AlecGhost)) 62 + 63 + - The compiler now uses a call graph for detecting unused types and values. 64 + This means that among other things, it can now detect unused recursive 65 + functions. For example: 66 + 67 + ```gleam 68 + // warning: unused 69 + fn some_recursive_function() { 70 + some_recursive_function() 71 + } 72 + ``` 73 + 74 + ([Surya Rose](https://github.com/GearsDatapacks)) 75 + 76 + - The compiler now emits a warning when using `let assert` to assert a value 77 + whose variant has already been inferred. For example: 78 + 79 + ```gleam 80 + // warning: This will always crash 81 + let assert Ok(_) = Error("Some error") 82 + ``` 83 + 84 + ([Surya Rose](https://github.com/GearsDatapacks)) 85 + 86 + - It is now possible to omit the `:float` option for literal floats used in a 87 + `BitArray` segment. 88 + 89 + ```gleam 90 + <<1.11>> 91 + ``` 92 + 93 + Is the same as: 94 + 95 + ```gleam 96 + <<1.11:float>> 97 + ``` 98 + 99 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 100 + 101 + - Compilation of binary operators is now fault tolerant and won't stop at the 102 + first type error. 103 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 104 + 105 + - The compiler now provides a better error message when using the wrong operator 106 + to try and join two strings together. For example: 107 + 108 + ```txt 109 + error: Type mismatch 110 + ┌─ /src/wibble.gleam:2:13 111 + 112 + 2 │ "Hello, " + "Lucy" 113 + │ ^ Use <> instead 114 + 115 + The + operator can only be used on Ints. 116 + To join two strings together you can use the <> operator. 117 + ``` 118 + 119 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 120 + 121 + - The compiler now provides a better error message when using an Int operator on 122 + Float values, suggesting the correct replacement. For example: 123 + 124 + ```txt 125 + error: Type mismatch 126 + ┌─ /Users/giacomocavalieri/Desktop/prova/src/prova.gleam:2:7 127 + 128 + 2 │ 1.0 + 2.0 129 + │ ^ Use +. instead 130 + 131 + The + operator can only be used on Ints. 132 + ``` 133 + 134 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 135 + 136 + - The compiler now provides a better error message when using a Float operator 137 + on Int values, suggesting the correct replacement. For example: 138 + 139 + ```txt 140 + error: Type mismatch 141 + ┌─ /Users/giacomocavalieri/Desktop/prova/src/prova.gleam:2:5 142 + 143 + 2 │ 1 >. 2 144 + │ ^^ Use > instead 145 + 146 + The >. operator can only be used on Floats. 147 + ``` 148 + 149 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 150 + 151 + - The compiler no longer shows errors for a function's labels if the called 152 + function itself doesn't exist. 153 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 154 + 155 + ### Build tool 156 + 157 + - Include a type annotation for the `main` function generated by `gleam new`. 158 + ([Drew Olson](https://github.com/drewolson)) 159 + 160 + - Two entry point scripts are now always generated by `gleam export erlang-shipment`: 161 + 162 + - `entrypoint.sh` for POSIX Shell 163 + - `entrypoint.ps1` for PowerShell 164 + 165 + ([Greg Burri](https://github.com/ummon)) 166 + 167 + - The `gleam export` command now takes a `package-information` option to 168 + export the project's `gleam.toml` as a JSON file. 169 + ([Rodrigo Álvarez](https://github.com/Papipo)) 170 + 171 + - Improved the error message when failing to encrypt or decrypt a local 172 + Hex API key. 173 + ([Samuel Cristobal](https://github.com/scristobal)) 174 + 175 + - The `HEXPM_USER` and `HEXPM_PASS` environment variables when running 176 + `gleam publish` have been deprecated in favour of `HEXPM_API_KEY`. 177 + ([Samuel Cristobal](https://github.com/scristobal)) 178 + 179 + - The "functions" and "constants" sections of generated HTML documentation have 180 + been merged into one "values" section. 181 + ([Sam Zanca](https://github.com/metruzanca)) 182 + 183 + ### Language server 184 + 185 + - The language server now allows renaming of functions, constants, 186 + custom type variants and custom types across modules. For example: 187 + 188 + ```gleam 189 + // wibble.gleam 190 + pub fn wibble() { 191 + wibble() 192 + //^ Trigger rename 193 + } 194 + // wobble.gleam 195 + import wibble 196 + 197 + pub fn main() { 198 + wibble.wibble() 199 + } 200 + ``` 201 + 202 + Becomes: 203 + 204 + ```gleam 205 + // wibble.gleam 206 + pub fn wobble() { 207 + wobble() 208 + } 209 + // wobble.gleam 210 + import wibble 211 + 212 + pub fn main() { 213 + wibble.wobble() 214 + } 215 + ``` 216 + 217 + ([Surya Rose](https://github.com/GearsDatapacks)) 218 + 219 + - The language server can now offer a code action to replace a `..` in a pattern 220 + with all the fields that are being ignored. For example triggering the code 221 + action on this spread: 222 + 223 + ```gleam 224 + pub type Pokemon { 225 + Pokemon(id: Int, name: String, moves: List(String)) 226 + } 227 + 228 + pub fn main() { 229 + let Pokemon(..) = todo 230 + // ^ If you put your cursor here 231 + } 232 + ``` 233 + 234 + Would generate the following code: 235 + 236 + ```gleam 237 + pub type Pokemon { 238 + Pokemon(id: Int, name: String, moves: List(String)) 239 + } 240 + 241 + pub fn main() { 242 + let Pokemon(id:, name:, moves:) = todo 243 + } 244 + ``` 245 + 246 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 247 + 248 + - The function generated by the "Generate JSON encoder" code action has been 249 + slightly modified so that it will now fail to compile if the type has new 250 + fields added, ensuring the programmer remembers to re-run the code action. 251 + For example, for this type: 252 + 253 + ```gleam 254 + type Person { 255 + Person(name: String, age: Int) 256 + } 257 + ``` 258 + 259 + The following code used to be generated: 260 + 261 + ```gleam 262 + fn encode_person(person: Person) -> json.Json { 263 + json.object([ 264 + #("name", json.string(person.name)), 265 + #("age", json.int(person.age)), 266 + ]) 267 + } 268 + ``` 269 + 270 + But now, this code is generated: 271 + 272 + ```gleam 273 + fn encode_person(person: Person) -> json.Json { 274 + let Person(name:, age:) = person 275 + json.object([ 276 + #("name", json.string(name)), 277 + #("age", json.int(age)), 278 + ]) 279 + } 280 + ``` 281 + 282 + ([Surya Rose](https://github.com/GearsDatapacks)) 283 + 284 + - The language server now supports finding references to values and types, 285 + both within a module and across multiple modules. 286 + ([Surya Rose](https://github.com/GearsDatapacks)) 287 + 288 + - The language server now offers a code action to remove all `echo`s in a 289 + module. For example: 290 + 291 + ```gleam 292 + pub fn main() { 293 + [1, 2, 3] 294 + |> echo 295 + // ^^^^ If you put your cursor over here 296 + |> list.filter(int.is_even) 297 + |> echo 298 + } 299 + ``` 300 + 301 + Triggering the code action would remove all the `echo` pipeline steps: 302 + 303 + ```gleam 304 + pub fn main() { 305 + [1, 2, 3] 306 + |> list.filter(int.is_even) 307 + } 308 + ``` 309 + 310 + This also works with all the `echo`s used before an expression: 311 + 312 + ```gleam 313 + pub fn main() { 314 + echo 1 + 2 315 + //^^^^^^^^^^ If hovering anywhere over here 316 + } 317 + ``` 318 + 319 + Triggering the code action would remove the `echo`: 320 + 321 + ```gleam 322 + pub fn main() { 323 + 1 + 2 324 + } 325 + ``` 326 + 327 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 328 + 329 + - The language server now offers a code action to replace a Float operator used 330 + on Int values with the correct operator. For example: 331 + 332 + ```gleam 333 + pub fn main() { 334 + 11 +. 1 335 + //^^^^^^^ When hovering anywhere over here 336 + } 337 + ``` 338 + 339 + Triggering the code action would fix the compilation error by using the 340 + correct Int operator: 341 + 342 + ```gleam 343 + pub fn main() { 344 + 11 + 1 345 + } 346 + ``` 347 + 348 + This also works the other way around: 349 + 350 + ```gleam 351 + pub fn main() { 352 + 1.1 + 10.0 353 + //^^^^^^^^^^ If hovering anywhere over here 354 + } 355 + ``` 356 + 357 + Triggering the code action would replace the wrong operator with the correct 358 + equivalent Float operator: 359 + 360 + ```gleam 361 + pub fn main() { 362 + 1.1 +. 10.0 363 + } 364 + ``` 365 + 366 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 367 + 368 + - If there's a compilation error because two strings are being joined with the 369 + wrong `+` operator (instead of using `<>`), the language server now offers a 370 + code action to fix the error automatically. For example: 371 + 372 + ```gleam 373 + pub fn main() { 374 + "Hello, " + "Jak" 375 + //^^^^^^^^^^^^^^^^^ When hovering anywhere over here 376 + } 377 + ``` 378 + 379 + Triggering the code action would fix the compilation error by using the 380 + correct `<>` operator instead of `+`: 381 + 382 + ```gleam 383 + pub fn main() { 384 + "Hello, " <> "Jak" 385 + } 386 + ``` 387 + 388 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 389 + 390 + - The language server now offers the option to lift expressions into consts. 391 + For example, in two uses of the code action: 392 + 393 + ```gleam 394 + pub fn main() { 395 + [#("a", 0), #("b", 1), #("a", 2)] 396 + |> key_filter("a") 397 + } 398 + ``` 399 + 400 + Becomes: 401 + 402 + ```gleam 403 + const values = [#("a", 0), #("b", 1), #("a", 2)] 404 + 405 + const string = "a" 406 + 407 + pub fn main() { 408 + values 409 + |> key_filter(string) 410 + } 411 + ``` 412 + 413 + ([Matias Carlander](https://github.com/matiascr)) 414 + 415 + - The language server will now only offer the code action to generate a JSON 416 + encoder if the `gleam_json` package is installed as a dependency. 417 + ([Surya Rose](https://github.com/GearsDatapacks)) 418 + 419 + - The language server will offer to wrap assignment or case clause values in 420 + blocks. Useful when adding more expressions to an existing case clause or 421 + variable assignment. 422 + 423 + ```gleam 424 + pub fn f(pokemon_type: PokemonType) { 425 + case pokemon_type { 426 + Water -> soak() 427 + // ^^^^^^ selecting the right-hand side of the `->` in a clause 428 + Fire -> burn() 429 + } 430 + } 431 + ``` 432 + 433 + Becomes 434 + 435 + ```gleam 436 + pub fn f(pokemon_type: PokemonType) { 437 + case pokemon_type { 438 + Water -> { 439 + soak() 440 + } 441 + Fire -> burn() 442 + } 443 + } 444 + ``` 445 + 446 + ([Matias Carlander](https://github.com/matiascr)) 447 + 448 + - The "Generate function" code action now uses labels or variable names to improve 449 + the names of generated arguments. For example: 450 + 451 + ```gleam 452 + pub fn main() { 453 + let language = English 454 + greet(language, name: "Louis") 455 + } 456 + ``` 457 + 458 + Will generate the following function: 459 + 460 + ```gleam 461 + pub fn greet(language: String, name name: String) -> a { 462 + todo 463 + } 464 + ``` 465 + 466 + ([Surya Rose](https://github.com/GearsDatapacks)) 467 + 468 + - The "Rewrite from `use`" code action now only triggers if the cursor is on the 469 + first line of the `use` expression to rewrite. 470 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 471 + 472 + ### Formatter 473 + 474 + ### Container images 475 + 476 + - Container images now contain Software Bill of Materials (SBoM) and SLSA 477 + Provenance information. 478 + ([Jonatan Männchen](https://github.com/maennchen)) 479 + 480 + ### Bug fixes 481 + 482 + - Fixed a bug where tuples with atoms in the first position could be 483 + incorrectly formatted by `echo`. 484 + ([Louis Pilfold](https://github.com/lpil)) 485 + 486 + - Fixed a bug where unlabelled arguments would be allowed after labelled 487 + arguments in variant constructor definitions. 488 + ([Surya Rose](https://github.com/GearsDatapacks)) 489 + 490 + - Fixed a bug where using the "Convert to pipe" code action on a function whose 491 + first argument is itself a pipe would result in invalid code. 492 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 493 + 494 + - Fixed a bug where using the "Convert to pipe" code action on a function or 495 + record capture produces invalid code. 496 + ([Matias Carlander](https://github.com/matiascr)) 497 + 498 + - Fixed a bug where a temporarily moved or removed file does not get recompiled, 499 + even though its dependencies changed in the meanwhile. 500 + ([Sakari Bergen](http://github.com/sbergen)) 501 + 502 + - Fixed a bug where the "Inline variable" code action would not work properly 503 + if used inside a record update. 504 + ([Surya Rose](https://github.com/GearsDatapacks)) 505 + 506 + - Fixed a bug where variant inference wouldn't work on `let assert` assignments. 507 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 508 + 509 + - Fixed a bug where the build tool could fail to lock the build directory but 510 + not report an error. 511 + ([Louis Pilfold](https://github.com/lpil)) 512 + 513 + - Fixed a bug where the language server would be too eager to recompile modules 514 + when it could use the cache from previous compilations. 515 + ([Louis Pilfold](https://github.com/lpil)) 516 + 517 + - Fixed a bug where `let assert` would not assert that the given value matched 518 + the pattern if it was the only expression inside a block. 519 + ([Surya Rose](https://github.com/GearsDatapacks)) 520 + 521 + - Fixed a bug where the code generated for `echo` on JavaScript could have name 522 + collisions if there are functions called `console` or `process`, or custom type 523 + variants called `Object` or `Deno` defined in the module. 524 + ([Louis Pilfold](https://github.com/lpil)) 525 + 526 + - Fixed a bug where the language server would stop working if the build 527 + directory was deleted e.g. as a result of `gleam clean`. 528 + ([Sakari Bergen](https://github.com/sbergen)) 529 + 530 + - Fixed a bug where the "Rewrite to pipe" code action could generate invalid 531 + code when the piped argument was a binary operation. 532 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 533 + 534 + - Fixed a bug where prelude types and values would be suggested in autocomplete 535 + when part of a module select. 536 + ([Surya Rose](https://github.com/GearsDatapacks)) 537 + 538 + - Fixed a bug where the check for multiple top-level modules when publishing 539 + would incorrectly print a warning. 540 + ([Surya Rose](https://github.com/GearsDatapacks)) 541 + 542 + ## v1.9.1 - 2025-03-10 543 + 544 + ### Formatter 545 + 546 + - Improved the formatting of pipelines printed with `echo`. 547 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 548 + 549 + ### Bug fixes 550 + 551 + - Fixed a bug where `echo` used before a pipeline would generate invalid code 552 + for the Erlang target. 553 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri))