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

Configure Feed

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

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