···2233## Unreleased
4455-### Bug fixes
66-77-- Corrected an error message that used incorrect terminology.
88- ([Louis Pilfold](https://github.com/lpil))
99-1010-## v1.12.0-rc3 - 2025-07-31
1111-1212-### Bug fixes
1313-1414-- Fixed a bug where using `echo` in a module with a function named `process`
1515- would result in a runtime error on JavaScript.
1616- ([Peter Saxton](https://github.com/CrowdHailer))
1717-1818-## v1.12.0-rc2 - 2025-07-24
1919-2020-### Formatter
2121-2222-- The formatter now allows more control over how bit arrays are split. By adding
2323- a trailing comma at the end of a bit array that can fit on a single line, the
2424- bit array will be split on multiple lines:
2525-2626- ```gleam
2727- pub fn dgram() -> BitArray {
2828- <<ip_version:4, header_length:4, service_type:8,>>
2929- }
3030- ```
3131-3232- Will be formatted as:
3333-3434- ```gleam
3535- pub fn dgram() -> BitArray {
3636- <<
3737- ip_version:4,
3838- header_length:4,
3939- service_type:8,
4040- >>
4141- }
4242- ```
4343-4444- By removing the trailing comma, the formatter will try and fit the bit array
4545- on a single line again:
4646-4747- ```gleam
4848- pub fn dgram() -> BitArray {
4949- <<
5050- ip_version:4,
5151- header_length:4,
5252- service_type:8
5353- >>
5454- }
5555- ```
5656-5757- Will be formatted back to a single line:
5858-5959- ```gleam
6060- pub fn dgram() -> BitArray {
6161- <<ip_version:4, header_length:4, service_type:8>>
6262- }
6363- ```
6464-6565- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
6666-6767-- The formatter now allows more control over how bit arrays are formatted.
6868- If a bit array is split with multiple segments on the same line, removing the
6969- trailing comma will make sure the formatter keeps each segment on its own
7070- line:
7171-7272- ```gleam
7373- pub fn dgram() -> BitArray {
7474- <<
7575- "This bit array was formatted", "keeping segments on the same line",
7676- "notice how the formatting changes by removing the trailing comma ->",
7777- >>
7878- }
7979- ```
8080-8181- Is formatted as:
8282-8383- ```gleam
8484- pub fn dgram() -> BitArray {
8585- <<
8686- "This bit array was formatted",
8787- "keeping segments on the same line",
8888- "notice how the formatting changes by removing the trailing comma ->"
8989- >>
9090- }
9191- ```
9292-9393- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
9494-9595-### Bug fixes
9696-9797-- Fixed a bug where the formatter would move a comment before `assert` to be
9898- after it.
9999- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
100100-101101-- Fixed a bug where the message following an `echo`, `panic`, `todo`, `assert`,
102102- or `let assert` would not be formatted properly when preceded by a comment.
103103- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
104104-105105-- Fixed a bug where the compiler would generate invalid code for an `assert`
106106- using pipes on the JavaScript target.
107107- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
108108-109109-## v1.12.0-rc1 - 2025-07-18
110110-1115### Compiler
1126113113-- It is now possible to add a custom message to be printed by `echo`, making it
114114- easier to include additional context to be printed at runtime:
115115-116116- ```gleam
117117- pub fn main() {
118118- echo 11 as "lucky number"
119119- }
120120- ```
121121-122122- Will output to stderr:
123123-124124- ```txt
125125- /src/module.gleam:2 lucky number
126126- 11
127127- ```
128128-129129- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
130130-131131-- Generated JavaScript functions, constants, and custom type constructors now
132132- include any doc comment as a JSDoc comment, making it easier to use the
133133- generated code and browse its documentation from JavaScript.
134134- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
135135-136136-- The code generated for a `case` expression on the JavaScript target is now
137137- reduced in size in many cases.
138138- ([Surya Rose](https://github.com/GearsDatapacks))
139139-140140-- The code generators now perform usage-based dead code elimination. Unused
141141- definitions are not longer generated.
142142- ([Louis Pilfold](https://github.com/lpil))
143143-144144-- `echo` now has better support for character lists, JavaScript errors, and
145145- JavaScript circular references.
146146- ([Louis Pilfold](https://github.com/lpil))
147147-148148-- The look of errors and warnings has been improved. Additional labels providing
149149- context for the error message are no longer highlighted with the same style as
150150- the source of the problem.
151151- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
152152-153153-- Gleam will now emit a helpful message when attempting to import modules using
154154- `.` instead of `/`.
155155-156156- ```txt
157157- error: Syntax error
158158- ┌─ /src/parse/error.gleam:1:11
159159- │
160160- 1 │ import one.two.three
161161- │ ^ I was expecting either `/` or `.{` here.
162162-163163- Perhaps you meant one of:
164164-165165- import one/two
166166- import one.{item}
167167- ```
168168-169169- ([Zij-IT](https://github.com/zij-it))
170170-171171-- The compiler now emits a warning when a top-level constant or function
172172- declaration shadows an imported name in the current module.
173173- ([Aayush Tripathi](https://github.com/aayush-tripathi))
174174-175175-- The compiler can now tell when an unknown variable might be referring to an
176176- ignored variable and provide an helpful error message highlighting it. For
177177- example, this piece of code:
178178-179179- ```gleam
180180- pub fn go() {
181181- let _x = 1
182182- x + 1
183183- }
184184- ```
185185-186186- Now results in the following error:
187187-188188- ```
189189- error: Unknown variable
190190- ┌─ /src/one/two.gleam:4:3
191191- │
192192- 3 │ let _x = 1
193193- │ -- This value is discarded
194194- 4 │ x + 1
195195- │ ^ So it is not in scope here.
196196-197197- Hint: Change `_x` to `x` or reference another variable
198198- ```
199199-200200- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
201201-202202-- The code generated for pattern matching has been optimised on the JavaScript
203203- target to reuse the matched variables when safe to do so. Take the following
204204- snippet of Gleam code:
205205-206206- ```gleam
207207- pub fn find_book() {
208208- case ask_for_isbn() {
209209- Ok(isbn) -> load_book(isbn)
210210- Error(Nil) -> Error(Nil)
211211- }
212212- }
213213- ```
214214-215215- Notice how in the `Error` case we're returning exactly the same value that is
216216- being matched on! Now the compiler will generate the following JavaScript code
217217- instead of allocating a new `Error` variant entirely:
218218-219219- ```js
220220- export function find_book() {
221221- let result = ask_for_isbn();
222222- if (result instanceof Ok) {
223223- let isbn = result[0];
224224- return load_book(isbn);
225225- } else {
226226- // Previously this would have been: `return new Error(undefined);`!
227227- return result;
228228- }
229229- }
230230- ```
231231-232232- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
233233-234234-- The compiler now raises a warning when performing a redundant comparison that
235235- it can tell is always going to succeed or fail. For example, this piece of
236236- code:
237237-238238- ```gleam
239239- pub fn find_line(lines) {
240240- list.find(lines, fn(x) { x == x })
241241- }
242242- ```
243243-244244- Would result in the following warning:
245245-246246- ```
247247- warning: Redundant comparison
248248- ┌─ /src/warning.gleam:2:17
249249- │
250250- 1 │ list.find(lines, fn(x) { x == x })
251251- │ ^^^^^^ This is always `True`
252252-253253- This comparison is redundant since it always succeeds.
254254- ```
255255-256256- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
257257-258258-- Attempting to use the list prefix syntax with two lists will now
259259- show a helpful error message. For example, this snippet of code:
260260-261261- ```gleam
262262- pub fn main() -> Nil {
263263- let xs = [1, 2, 3]
264264- let ys = [5, 6, 7]
265265- [1, ..xs, ..ys]
266266- }
267267- ```
268268-269269- Would result in the following error:
270270-271271- ```
272272- error: Syntax error
273273- ┌─ /src/parse/error.gleam:5:13
274274- │
275275- 5 │ [1, ..xs, ..ys]
276276- │ -- ^^ I wasn't expecting a second list here
277277- │ │
278278- │ You're using a list here
279279-280280- Lists are immutable and singly-linked, so to join two or more lists
281281- all the elements of the lists would need to be copied into a new list.
282282- This would be slow, so there is no built-in syntax for it.
283283- ```
284284-285285- ([Carl Bordum Hansen](https://github.com/carlbordum)) and
286286- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
287287-288288-- The error message one gets when calling a function with the wrong number of
289289- arguments has been improved and now only suggests the relevant missing labels.
290290- For example, this piece of code:
291291-292292- ```gleam
293293- pub type Pokemon {
294294- Pokemon(id: Int, name: String, moves: List(String))
295295- }
296296-297297- pub fn best_pokemon() {
298298- Pokemon(198, name: "murkrow")
299299- }
300300- ```
301301-302302- Would result in the following error, suggesting the missing labels:
303303-304304- ```txt
305305- error: Incorrect arity
306306- ┌─ /src/main.gleam:6:3
307307- │
308308- 6 │ Pokemon(198, name: "murkrow")
309309- │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Expected 3 arguments, got 2
310310-311311- This call accepts these additional labelled arguments:
312312-313313- - moves
314314- ```
315315-316316- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
317317-318318-- Code generators now reuse existing variables when possible for the record
319319- update syntax, reducing the size of the generated code and number of
320320- variables defined for both Erlang and JavaScript.
321321-322322- ```gleam
323323- pub fn main() -> Nil {
324324- let trainer = Trainer(name: "Ash", badges: 0)
325325- battle(Trainer(..trainer, badges: 1))
326326- }
327327- ```
328328-329329- Previously this Gleam code would generate this Erlang code:
330330-331331- ```erlang
332332- -spec main() -> nil.
333333- main() ->
334334- Trainer = {trainer, 0, <<"Ash"/utf8>>},
335335- battle(
336336- begin
337337- _record = Trainer,
338338- {trainer, 1, erlang:element(3, _record)}
339339- end
340340- ).
341341- ```
342342-343343- Now this code will be generated instead:
344344-345345- ```erlang
346346- -spec main() -> nil.
347347- main() ->
348348- Trainer = {trainer, 0, <<"Ash"/utf8>>},
349349- battle({trainer, 1, erlang:element(3, Trainer)}).
350350- ```
351351-352352- ([Louis Pilfold](https://github.com/lpil))
353353-354354-- The compiler now allows using bit array options to specify endianness when
355355- constructing or pattern matching on UTF codepoints in bit arrays.
356356- ([Surya Rose](https://github.com/GearsDatapacks))
357357-358358-- Calculations are now allowed in the size options of bit array patterns. For
359359- example, the following code is now valid:
360360-361361- ```gleam
362362- let assert <<size, data:bytes-size(size / 8 - 1)>> = some_bit_array
363363- ```
364364-365365- ([Surya Rose](https://github.com/GearsDatapacks))
366366-367367-- On the Erlang target each generated module enables inlining from the Erlang
368368- compiler.
369369- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
370370-371371-- The code generated for division and modulo operators on the JavaScript target
372372- has been improved to avoid performing needless checks.
373373- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
374374-3757### Build tool
3768377377-- `gleam update`, `gleam deps update`, and `gleam deps download` will now print
378378- a message when there are new major versions of packages available. For
379379- example:
380380-381381- ```text
382382- $ gleam update
383383- Resolving versions
384384-385385- The following dependencies have new major versions available:
386386-387387- gleam_http 1.7.0 -> 4.0.0
388388- gleam_json 1.0.1 -> 3.0.1
389389- lustre 3.1.4 -> 5.1.1
390390- ```
391391-392392- ([Amjad Mohamed](https://github.com/andho))
393393-394394-- The documentation generator now strips trailing slashes from Gitea/Forgejo
395395- hosts so sidebar "Repository" and "View Source" links never include `//`, and
396396- single-line "View Source" anchors emit `#Lx` instead of `#Lx-x`.
397397- ([Aayush Tripathi](https://github.com/aayush-tripathi))
398398-399399-- The build tool can now compile packages that will have already booted the
400400- Erlang compiler application instead of failing.
401401- ([Louis Pilfold](https://github.com/lpil))
402402-403403-- `gleam deps list` now uses a tab rather than a space as a separator.
404404- ([Louis Pilfold](https://github.com/lpil))
405405-406406-- The build tool now also supports `.cjs` files placed in the `src`, `dev` or
407407- `test` directories.
408408- ([yoshi](https://github.com/yoshi-monster))
409409-410410-- The build tool now produces better error messages when version resolution
411411- fails. For example:
412412-413413- ```
414414- $ gleam add wisp@1
415415- Resolving versions
416416- error: Dependency resolution failed
417417-418418- There's no compatible version of `gleam_otp`:
419419- - You require wisp >= 1.0.0 and < 2.0.0
420420- - wisp requires mist >= 1.2.0 and < 5.0.0
421421- - mist requires gleam_otp >= 0.9.0 and < 1.0.0
422422- - You require lustre >= 5.2.1 and < 6.0.0
423423- - lustre requires gleam_otp >= 1.0.0 and < 2.0.0
424424-425425- There's no compatible version of `gleam_json`:
426426- - You require wisp >= 1.0.0 and < 2.0.0
427427- - wisp requires gleam_json >= 3.0.0 and < 4.0.0
428428- - You require gleam_json >= 2.3.0 and < 3.0.0
429429- ```
430430-431431- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
432432-433433-- The `repository` section in `gleam.toml` now allows specifying the
434434- `tag-prefix` property, which is prepended to the default tag.
435435- This makes it possible to have multiple packages with different versions in
436436- the same repository (together with `path`), without breaking links to source
437437- code in documentation.
438438- ([Sakari Bergen](https://github.com/sbergen))
439439-4409### Language server
44110442442-- It is now possible to use the "Pattern match on variable" code action on
443443- variables on the left hand side of a `use`. For example:
444444-445445- ```gleam
446446- pub type User {
447447- User(id: Int, name: String)
448448- }
449449-450450- pub fn main() {
451451- use user <- result.try(load_user())
452452- // ^^^^ Triggering the code action here
453453- todo
454454- }
455455- ```
456456-457457- Would result in the following code:
458458-459459- ```gleam
460460- pub type User {
461461- User(id: Int, name: String)
462462- }
463463-464464- pub fn main() {
465465- use user <- result.try(load_user())
466466- let User(id:, name:) = user
467467- todo
468468- }
469469- ```
470470-471471- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
472472-473473-- The "generate function" and "generate variant" code actions are now
474474- quickfixes, allowing them to be more easily applied to code which is producing
475475- an error.
476476- ([Surya Rose](https://github.com/GearsDatapacks))
477477-478478-- The language server now offers a code action to remove needless blocks
479479- wrapping a single expression. For example, in this code snippet:
480480-481481- ```gleam
482482- case greeting {
483483- User(name:) -> { "Hello, " <> name }
484484- // ^^^^^^^^^^^^^^^^^^^^^ Triggering the code action
485485- // with the cursor over this block.
486486- Anonymous -> "Hello, stranger!"
487487- }
488488- ```
489489-490490- Would be turned into:
491491-492492- ```gleam
493493- case greeting {
494494- User(name:) -> "Hello, " <> name
495495- Anonymous -> "Hello, stranger!"
496496- }
497497- ```
498498-499499- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
500500-501501-- It is now possible to trigger the "Add type annotation" code action anywhere
502502- between the start of a function definition and the start of its body. For
503503- example the action can trigger here while it previously wouldn't:
504504-505505- ```gleam
506506- pub fn my_lucky_number() {
507507- // ^^ The action can trigger here as well!
508508- 11
509509- }
510510- ```
511511-512512- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
513513-51411### Formatter
51512516516-- The formatter now allows more control over how lists are split. By adding a
517517- trailing comma at the end of a list that can fit on a single line, the list
518518- will be split on multiple lines:
519519-520520- ```gleam
521521- pub fn my_favourite_pokemon() -> List(String) {
522522- ["natu", "chimecho", "milotic",]
523523- }
524524- ```
525525-526526- Will be formatted as:
527527-528528- ```gleam
529529- pub fn my_favourite_pokemon() -> List(String) {
530530- [
531531- "natu",
532532- "chimecho",
533533- "milotic",
534534- ]
535535- }
536536- ```
537537-538538- By removing the trailing comma, the formatter will try and fit the list on a
539539- single line again:
540540-541541- ```gleam
542542- pub fn my_favourite_pokemon() -> List(String) {
543543- [
544544- "natu",
545545- "chimecho",
546546- "milotic"
547547- ]
548548- }
549549- ```
550550-551551- Will be formatted back to a single line:
552552-553553- ```gleam
554554- pub fn my_favourite_pokemon() -> List(String) {
555555- ["natu", "chimecho", "milotic"]
556556- }
557557- ```
558558-559559- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
560560-561561-- The formatter now allows more control over how lists are formatted.
562562- If a list is split with multiple elements on the same line, removing the
563563- trailing comma will make sure the formatter keeps each item on its own line:
564564-565565- ```gleam
566566- pub fn my_favourite_pokemon() -> List(String) {
567567- [
568568- "This list was formatted", "keeping multiple elements on the same line",
569569- "notice how the formatting changes by removing the trailing comma ->"
570570- ]
571571- }
572572- ```
573573-574574- Is formatted as:
575575-576576- ```gleam
577577- pub fn my_favourite_pokemon() -> List(String) {
578578- [
579579- "This list was formatted",
580580- "keeping multiple elements on the same line",
581581- "notice how the formatting changes by removing the trailing comma ->",
582582- ]
583583- }
584584- ```
585585-586586- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
587587-588588-- The formatter no longer removes empty lines between list items. In case an
589589- empty line is added between list items they will all be split on multiple
590590- lines. For example:
591591-592592- ```gleam
593593- pub fn main() {
594594- [
595595- "natu", "xatu",
596596-597597- "chimeco"
598598- ]
599599- }
600600- ```
601601-602602- Is formatted as:
603603-604604- ```gleam
605605- pub fn main() {
606606- [
607607- "natu",
608608- "xatu",
609609-610610- "chimeco",
611611- ]
612612- }
613613- ```
614614-615615- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
616616-61713### Bug fixes
618618-619619-- Fixed a bug where the language server would not show type-related code actions
620620- for record fields in custom type definitions.
621621- ([cysabi](https://github.com/cysabi))
622622-623623-- Fixed a bug where the "Inline variable" code action would be offered for
624624- function parameters and other invalid cases.
625625- ([Surya Rose](https://github.com/GearsDatapacks))
626626-627627-- Fixed a bug where the "Inline variable" code action would not be applied
628628- correctly to variables using label shorthand syntax.
629629- ([Surya Rose](https://github.com/GearsDatapacks))
630630-631631-- Fixed a bug where the compiler would emit the same error twice for patterns
632632- with the wrong number of labels.
633633- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
634634-635635-- Fixed a bug where the language server would generate invalid code when the
636636- "Extract variable" code action was used on a `use` expression.
637637- ([Surya Rose](https://github.com/GearsDatapacks))
638638-639639-- Fixed a bug where the compiler would crash when using the `utf8_codepoint`
640640- bit array segment on the JavaScript target.
641641- ([Surya Rose](https://github.com/GearsDatapacks))
642642-643643-- Fixed a bug where `==` and `!=` would return incorrect output for some
644644- JavaScript objects.
645645- ([Louis Pilfold](https://github.com/lpil))
646646-647647-- Fixed a bug where specific combinations of options in bit array segments would
648648- not be allowed on the JavaScript target.
649649- ([Surya Rose](https://github.com/GearsDatapacks))
650650-651651-- Fixed a bug where invalid code would be generated for `let assert` in some
652652- cases on the JavaScript target.
653653- ([Surya Rose](https://github.com/GearsDatapacks))
654654-655655-- Fixed a bug where using the prelude `Ok` and `Error` values in a qualified
656656- fashion could cause a conflict with user-defined `Ok` and `Error` values when
657657- generating code on the JavaScript target.
658658- ([Surya Rose](https://github.com/GearsDatapacks))
659659-660660-- Fixed a bug where the "Import module" code action would suggest importing
661661- internal modules from other packages.
662662- ([Surya Rose](https://github.com/GearsDatapacks))
663663-664664-- Fixed a bug where the language server would not rename variables defined in
665665- alternative patterns.
666666- ([Surya Rose](https://github.com/GearsDatapacks))
667667-668668-- Fixed a bug where trying to rename a type or value from the Gleam prelude
669669- would result in invalid code.
670670- ([Surya Rose](https://github.com/GearsDatapacks))
671671-672672-- Fixed a bug where the generated documentation would not be formatted properly.
673673- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
674674-675675-- Fixed a bug where the language server wouldn't allow you to jump to the
676676- definition of a record from a record update expression.
677677- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
678678-679679-- Fixed a bug where the language server would allow using the "extract variable"
680680- code action on variables used in record updates.
681681- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
682682-683683-- Fixed a bug where a record pattern with a spread `..` would not be formatted
684684- properly.
685685- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
686686-687687-- Fixed a bug where fields of custom types named `prototype` would not be
688688- properly escaped on the JavaScript target.
689689- ([Surya Rose](https://github.com/GearsDatapacks))
690690-691691-## v1.11.1 - 2025-06-05
692692-693693-### Compiler
694694-695695-- The displaying of internal types in HTML documentation has been improved.
696696- ([Louis Pilfold](https://github.com/lpil))
697697-698698-- A warning is now emitted when the same module is imported
699699- multiple times into the same module with different aliases.
700700- ([Louis Pilfold](https://github.com/lpil))
701701-702702-### Bug fixes
703703-704704-- Fixed a bug where a bit array segment matching on a floating point number
705705- would match with `NaN` or `Infinity` on the JavaScript target.
706706- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
+706
changelog/v1.12.md
···11+# Changelog
22+33+## v1.12.0 - 2025-08-05
44+55+### Bug fixes
66+77+- Corrected an error message that used incorrect terminology.
88+ ([Louis Pilfold](https://github.com/lpil))
99+1010+## v1.12.0-rc3 - 2025-07-31
1111+1212+### Bug fixes
1313+1414+- Fixed a bug where using `echo` in a module with a function named `process`
1515+ would result in a runtime error on JavaScript.
1616+ ([Peter Saxton](https://github.com/CrowdHailer))
1717+1818+## v1.12.0-rc2 - 2025-07-24
1919+2020+### Formatter
2121+2222+- The formatter now allows more control over how bit arrays are split. By adding
2323+ a trailing comma at the end of a bit array that can fit on a single line, the
2424+ bit array will be split on multiple lines:
2525+2626+ ```gleam
2727+ pub fn dgram() -> BitArray {
2828+ <<ip_version:4, header_length:4, service_type:8,>>
2929+ }
3030+ ```
3131+3232+ Will be formatted as:
3333+3434+ ```gleam
3535+ pub fn dgram() -> BitArray {
3636+ <<
3737+ ip_version:4,
3838+ header_length:4,
3939+ service_type:8,
4040+ >>
4141+ }
4242+ ```
4343+4444+ By removing the trailing comma, the formatter will try and fit the bit array
4545+ on a single line again:
4646+4747+ ```gleam
4848+ pub fn dgram() -> BitArray {
4949+ <<
5050+ ip_version:4,
5151+ header_length:4,
5252+ service_type:8
5353+ >>
5454+ }
5555+ ```
5656+5757+ Will be formatted back to a single line:
5858+5959+ ```gleam
6060+ pub fn dgram() -> BitArray {
6161+ <<ip_version:4, header_length:4, service_type:8>>
6262+ }
6363+ ```
6464+6565+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
6666+6767+- The formatter now allows more control over how bit arrays are formatted.
6868+ If a bit array is split with multiple segments on the same line, removing the
6969+ trailing comma will make sure the formatter keeps each segment on its own
7070+ line:
7171+7272+ ```gleam
7373+ pub fn dgram() -> BitArray {
7474+ <<
7575+ "This bit array was formatted", "keeping segments on the same line",
7676+ "notice how the formatting changes by removing the trailing comma ->",
7777+ >>
7878+ }
7979+ ```
8080+8181+ Is formatted as:
8282+8383+ ```gleam
8484+ pub fn dgram() -> BitArray {
8585+ <<
8686+ "This bit array was formatted",
8787+ "keeping segments on the same line",
8888+ "notice how the formatting changes by removing the trailing comma ->"
8989+ >>
9090+ }
9191+ ```
9292+9393+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
9494+9595+### Bug fixes
9696+9797+- Fixed a bug where the formatter would move a comment before `assert` to be
9898+ after it.
9999+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
100100+101101+- Fixed a bug where the message following an `echo`, `panic`, `todo`, `assert`,
102102+ or `let assert` would not be formatted properly when preceded by a comment.
103103+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
104104+105105+- Fixed a bug where the compiler would generate invalid code for an `assert`
106106+ using pipes on the JavaScript target.
107107+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
108108+109109+## v1.12.0-rc1 - 2025-07-18
110110+111111+### Compiler
112112+113113+- It is now possible to add a custom message to be printed by `echo`, making it
114114+ easier to include additional context to be printed at runtime:
115115+116116+ ```gleam
117117+ pub fn main() {
118118+ echo 11 as "lucky number"
119119+ }
120120+ ```
121121+122122+ Will output to stderr:
123123+124124+ ```txt
125125+ /src/module.gleam:2 lucky number
126126+ 11
127127+ ```
128128+129129+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
130130+131131+- Generated JavaScript functions, constants, and custom type constructors now
132132+ include any doc comment as a JSDoc comment, making it easier to use the
133133+ generated code and browse its documentation from JavaScript.
134134+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
135135+136136+- The code generated for a `case` expression on the JavaScript target is now
137137+ reduced in size in many cases.
138138+ ([Surya Rose](https://github.com/GearsDatapacks))
139139+140140+- The code generators now perform usage-based dead code elimination. Unused
141141+ definitions are not longer generated.
142142+ ([Louis Pilfold](https://github.com/lpil))
143143+144144+- `echo` now has better support for character lists, JavaScript errors, and
145145+ JavaScript circular references.
146146+ ([Louis Pilfold](https://github.com/lpil))
147147+148148+- The look of errors and warnings has been improved. Additional labels providing
149149+ context for the error message are no longer highlighted with the same style as
150150+ the source of the problem.
151151+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
152152+153153+- Gleam will now emit a helpful message when attempting to import modules using
154154+ `.` instead of `/`.
155155+156156+ ```txt
157157+ error: Syntax error
158158+ ┌─ /src/parse/error.gleam:1:11
159159+ │
160160+ 1 │ import one.two.three
161161+ │ ^ I was expecting either `/` or `.{` here.
162162+163163+ Perhaps you meant one of:
164164+165165+ import one/two
166166+ import one.{item}
167167+ ```
168168+169169+ ([Zij-IT](https://github.com/zij-it))
170170+171171+- The compiler now emits a warning when a top-level constant or function
172172+ declaration shadows an imported name in the current module.
173173+ ([Aayush Tripathi](https://github.com/aayush-tripathi))
174174+175175+- The compiler can now tell when an unknown variable might be referring to an
176176+ ignored variable and provide an helpful error message highlighting it. For
177177+ example, this piece of code:
178178+179179+ ```gleam
180180+ pub fn go() {
181181+ let _x = 1
182182+ x + 1
183183+ }
184184+ ```
185185+186186+ Now results in the following error:
187187+188188+ ```
189189+ error: Unknown variable
190190+ ┌─ /src/one/two.gleam:4:3
191191+ │
192192+ 3 │ let _x = 1
193193+ │ -- This value is discarded
194194+ 4 │ x + 1
195195+ │ ^ So it is not in scope here.
196196+197197+ Hint: Change `_x` to `x` or reference another variable
198198+ ```
199199+200200+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
201201+202202+- The code generated for pattern matching has been optimised on the JavaScript
203203+ target to reuse the matched variables when safe to do so. Take the following
204204+ snippet of Gleam code:
205205+206206+ ```gleam
207207+ pub fn find_book() {
208208+ case ask_for_isbn() {
209209+ Ok(isbn) -> load_book(isbn)
210210+ Error(Nil) -> Error(Nil)
211211+ }
212212+ }
213213+ ```
214214+215215+ Notice how in the `Error` case we're returning exactly the same value that is
216216+ being matched on! Now the compiler will generate the following JavaScript code
217217+ instead of allocating a new `Error` variant entirely:
218218+219219+ ```js
220220+ export function find_book() {
221221+ let result = ask_for_isbn();
222222+ if (result instanceof Ok) {
223223+ let isbn = result[0];
224224+ return load_book(isbn);
225225+ } else {
226226+ // Previously this would have been: `return new Error(undefined);`!
227227+ return result;
228228+ }
229229+ }
230230+ ```
231231+232232+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
233233+234234+- The compiler now raises a warning when performing a redundant comparison that
235235+ it can tell is always going to succeed or fail. For example, this piece of
236236+ code:
237237+238238+ ```gleam
239239+ pub fn find_line(lines) {
240240+ list.find(lines, fn(x) { x == x })
241241+ }
242242+ ```
243243+244244+ Would result in the following warning:
245245+246246+ ```
247247+ warning: Redundant comparison
248248+ ┌─ /src/warning.gleam:2:17
249249+ │
250250+ 1 │ list.find(lines, fn(x) { x == x })
251251+ │ ^^^^^^ This is always `True`
252252+253253+ This comparison is redundant since it always succeeds.
254254+ ```
255255+256256+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
257257+258258+- Attempting to use the list prefix syntax with two lists will now
259259+ show a helpful error message. For example, this snippet of code:
260260+261261+ ```gleam
262262+ pub fn main() -> Nil {
263263+ let xs = [1, 2, 3]
264264+ let ys = [5, 6, 7]
265265+ [1, ..xs, ..ys]
266266+ }
267267+ ```
268268+269269+ Would result in the following error:
270270+271271+ ```
272272+ error: Syntax error
273273+ ┌─ /src/parse/error.gleam:5:13
274274+ │
275275+ 5 │ [1, ..xs, ..ys]
276276+ │ -- ^^ I wasn't expecting a second list here
277277+ │ │
278278+ │ You're using a list here
279279+280280+ Lists are immutable and singly-linked, so to join two or more lists
281281+ all the elements of the lists would need to be copied into a new list.
282282+ This would be slow, so there is no built-in syntax for it.
283283+ ```
284284+285285+ ([Carl Bordum Hansen](https://github.com/carlbordum)) and
286286+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
287287+288288+- The error message one gets when calling a function with the wrong number of
289289+ arguments has been improved and now only suggests the relevant missing labels.
290290+ For example, this piece of code:
291291+292292+ ```gleam
293293+ pub type Pokemon {
294294+ Pokemon(id: Int, name: String, moves: List(String))
295295+ }
296296+297297+ pub fn best_pokemon() {
298298+ Pokemon(198, name: "murkrow")
299299+ }
300300+ ```
301301+302302+ Would result in the following error, suggesting the missing labels:
303303+304304+ ```txt
305305+ error: Incorrect arity
306306+ ┌─ /src/main.gleam:6:3
307307+ │
308308+ 6 │ Pokemon(198, name: "murkrow")
309309+ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Expected 3 arguments, got 2
310310+311311+ This call accepts these additional labelled arguments:
312312+313313+ - moves
314314+ ```
315315+316316+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
317317+318318+- Code generators now reuse existing variables when possible for the record
319319+ update syntax, reducing the size of the generated code and number of
320320+ variables defined for both Erlang and JavaScript.
321321+322322+ ```gleam
323323+ pub fn main() -> Nil {
324324+ let trainer = Trainer(name: "Ash", badges: 0)
325325+ battle(Trainer(..trainer, badges: 1))
326326+ }
327327+ ```
328328+329329+ Previously this Gleam code would generate this Erlang code:
330330+331331+ ```erlang
332332+ -spec main() -> nil.
333333+ main() ->
334334+ Trainer = {trainer, 0, <<"Ash"/utf8>>},
335335+ battle(
336336+ begin
337337+ _record = Trainer,
338338+ {trainer, 1, erlang:element(3, _record)}
339339+ end
340340+ ).
341341+ ```
342342+343343+ Now this code will be generated instead:
344344+345345+ ```erlang
346346+ -spec main() -> nil.
347347+ main() ->
348348+ Trainer = {trainer, 0, <<"Ash"/utf8>>},
349349+ battle({trainer, 1, erlang:element(3, Trainer)}).
350350+ ```
351351+352352+ ([Louis Pilfold](https://github.com/lpil))
353353+354354+- The compiler now allows using bit array options to specify endianness when
355355+ constructing or pattern matching on UTF codepoints in bit arrays.
356356+ ([Surya Rose](https://github.com/GearsDatapacks))
357357+358358+- Calculations are now allowed in the size options of bit array patterns. For
359359+ example, the following code is now valid:
360360+361361+ ```gleam
362362+ let assert <<size, data:bytes-size(size / 8 - 1)>> = some_bit_array
363363+ ```
364364+365365+ ([Surya Rose](https://github.com/GearsDatapacks))
366366+367367+- On the Erlang target each generated module enables inlining from the Erlang
368368+ compiler.
369369+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
370370+371371+- The code generated for division and modulo operators on the JavaScript target
372372+ has been improved to avoid performing needless checks.
373373+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
374374+375375+### Build tool
376376+377377+- `gleam update`, `gleam deps update`, and `gleam deps download` will now print
378378+ a message when there are new major versions of packages available. For
379379+ example:
380380+381381+ ```text
382382+ $ gleam update
383383+ Resolving versions
384384+385385+ The following dependencies have new major versions available:
386386+387387+ gleam_http 1.7.0 -> 4.0.0
388388+ gleam_json 1.0.1 -> 3.0.1
389389+ lustre 3.1.4 -> 5.1.1
390390+ ```
391391+392392+ ([Amjad Mohamed](https://github.com/andho))
393393+394394+- The documentation generator now strips trailing slashes from Gitea/Forgejo
395395+ hosts so sidebar "Repository" and "View Source" links never include `//`, and
396396+ single-line "View Source" anchors emit `#Lx` instead of `#Lx-x`.
397397+ ([Aayush Tripathi](https://github.com/aayush-tripathi))
398398+399399+- The build tool can now compile packages that will have already booted the
400400+ Erlang compiler application instead of failing.
401401+ ([Louis Pilfold](https://github.com/lpil))
402402+403403+- `gleam deps list` now uses a tab rather than a space as a separator.
404404+ ([Louis Pilfold](https://github.com/lpil))
405405+406406+- The build tool now also supports `.cjs` files placed in the `src`, `dev` or
407407+ `test` directories.
408408+ ([yoshi](https://github.com/yoshi-monster))
409409+410410+- The build tool now produces better error messages when version resolution
411411+ fails. For example:
412412+413413+ ```
414414+ $ gleam add wisp@1
415415+ Resolving versions
416416+ error: Dependency resolution failed
417417+418418+ There's no compatible version of `gleam_otp`:
419419+ - You require wisp >= 1.0.0 and < 2.0.0
420420+ - wisp requires mist >= 1.2.0 and < 5.0.0
421421+ - mist requires gleam_otp >= 0.9.0 and < 1.0.0
422422+ - You require lustre >= 5.2.1 and < 6.0.0
423423+ - lustre requires gleam_otp >= 1.0.0 and < 2.0.0
424424+425425+ There's no compatible version of `gleam_json`:
426426+ - You require wisp >= 1.0.0 and < 2.0.0
427427+ - wisp requires gleam_json >= 3.0.0 and < 4.0.0
428428+ - You require gleam_json >= 2.3.0 and < 3.0.0
429429+ ```
430430+431431+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
432432+433433+- The `repository` section in `gleam.toml` now allows specifying the
434434+ `tag-prefix` property, which is prepended to the default tag.
435435+ This makes it possible to have multiple packages with different versions in
436436+ the same repository (together with `path`), without breaking links to source
437437+ code in documentation.
438438+ ([Sakari Bergen](https://github.com/sbergen))
439439+440440+### Language server
441441+442442+- It is now possible to use the "Pattern match on variable" code action on
443443+ variables on the left hand side of a `use`. For example:
444444+445445+ ```gleam
446446+ pub type User {
447447+ User(id: Int, name: String)
448448+ }
449449+450450+ pub fn main() {
451451+ use user <- result.try(load_user())
452452+ // ^^^^ Triggering the code action here
453453+ todo
454454+ }
455455+ ```
456456+457457+ Would result in the following code:
458458+459459+ ```gleam
460460+ pub type User {
461461+ User(id: Int, name: String)
462462+ }
463463+464464+ pub fn main() {
465465+ use user <- result.try(load_user())
466466+ let User(id:, name:) = user
467467+ todo
468468+ }
469469+ ```
470470+471471+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
472472+473473+- The "generate function" and "generate variant" code actions are now
474474+ quickfixes, allowing them to be more easily applied to code which is producing
475475+ an error.
476476+ ([Surya Rose](https://github.com/GearsDatapacks))
477477+478478+- The language server now offers a code action to remove needless blocks
479479+ wrapping a single expression. For example, in this code snippet:
480480+481481+ ```gleam
482482+ case greeting {
483483+ User(name:) -> { "Hello, " <> name }
484484+ // ^^^^^^^^^^^^^^^^^^^^^ Triggering the code action
485485+ // with the cursor over this block.
486486+ Anonymous -> "Hello, stranger!"
487487+ }
488488+ ```
489489+490490+ Would be turned into:
491491+492492+ ```gleam
493493+ case greeting {
494494+ User(name:) -> "Hello, " <> name
495495+ Anonymous -> "Hello, stranger!"
496496+ }
497497+ ```
498498+499499+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
500500+501501+- It is now possible to trigger the "Add type annotation" code action anywhere
502502+ between the start of a function definition and the start of its body. For
503503+ example the action can trigger here while it previously wouldn't:
504504+505505+ ```gleam
506506+ pub fn my_lucky_number() {
507507+ // ^^ The action can trigger here as well!
508508+ 11
509509+ }
510510+ ```
511511+512512+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
513513+514514+### Formatter
515515+516516+- The formatter now allows more control over how lists are split. By adding a
517517+ trailing comma at the end of a list that can fit on a single line, the list
518518+ will be split on multiple lines:
519519+520520+ ```gleam
521521+ pub fn my_favourite_pokemon() -> List(String) {
522522+ ["natu", "chimecho", "milotic",]
523523+ }
524524+ ```
525525+526526+ Will be formatted as:
527527+528528+ ```gleam
529529+ pub fn my_favourite_pokemon() -> List(String) {
530530+ [
531531+ "natu",
532532+ "chimecho",
533533+ "milotic",
534534+ ]
535535+ }
536536+ ```
537537+538538+ By removing the trailing comma, the formatter will try and fit the list on a
539539+ single line again:
540540+541541+ ```gleam
542542+ pub fn my_favourite_pokemon() -> List(String) {
543543+ [
544544+ "natu",
545545+ "chimecho",
546546+ "milotic"
547547+ ]
548548+ }
549549+ ```
550550+551551+ Will be formatted back to a single line:
552552+553553+ ```gleam
554554+ pub fn my_favourite_pokemon() -> List(String) {
555555+ ["natu", "chimecho", "milotic"]
556556+ }
557557+ ```
558558+559559+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
560560+561561+- The formatter now allows more control over how lists are formatted.
562562+ If a list is split with multiple elements on the same line, removing the
563563+ trailing comma will make sure the formatter keeps each item on its own line:
564564+565565+ ```gleam
566566+ pub fn my_favourite_pokemon() -> List(String) {
567567+ [
568568+ "This list was formatted", "keeping multiple elements on the same line",
569569+ "notice how the formatting changes by removing the trailing comma ->"
570570+ ]
571571+ }
572572+ ```
573573+574574+ Is formatted as:
575575+576576+ ```gleam
577577+ pub fn my_favourite_pokemon() -> List(String) {
578578+ [
579579+ "This list was formatted",
580580+ "keeping multiple elements on the same line",
581581+ "notice how the formatting changes by removing the trailing comma ->",
582582+ ]
583583+ }
584584+ ```
585585+586586+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
587587+588588+- The formatter no longer removes empty lines between list items. In case an
589589+ empty line is added between list items they will all be split on multiple
590590+ lines. For example:
591591+592592+ ```gleam
593593+ pub fn main() {
594594+ [
595595+ "natu", "xatu",
596596+597597+ "chimeco"
598598+ ]
599599+ }
600600+ ```
601601+602602+ Is formatted as:
603603+604604+ ```gleam
605605+ pub fn main() {
606606+ [
607607+ "natu",
608608+ "xatu",
609609+610610+ "chimeco",
611611+ ]
612612+ }
613613+ ```
614614+615615+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
616616+617617+### Bug fixes
618618+619619+- Fixed a bug where the language server would not show type-related code actions
620620+ for record fields in custom type definitions.
621621+ ([cysabi](https://github.com/cysabi))
622622+623623+- Fixed a bug where the "Inline variable" code action would be offered for
624624+ function parameters and other invalid cases.
625625+ ([Surya Rose](https://github.com/GearsDatapacks))
626626+627627+- Fixed a bug where the "Inline variable" code action would not be applied
628628+ correctly to variables using label shorthand syntax.
629629+ ([Surya Rose](https://github.com/GearsDatapacks))
630630+631631+- Fixed a bug where the compiler would emit the same error twice for patterns
632632+ with the wrong number of labels.
633633+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
634634+635635+- Fixed a bug where the language server would generate invalid code when the
636636+ "Extract variable" code action was used on a `use` expression.
637637+ ([Surya Rose](https://github.com/GearsDatapacks))
638638+639639+- Fixed a bug where the compiler would crash when using the `utf8_codepoint`
640640+ bit array segment on the JavaScript target.
641641+ ([Surya Rose](https://github.com/GearsDatapacks))
642642+643643+- Fixed a bug where `==` and `!=` would return incorrect output for some
644644+ JavaScript objects.
645645+ ([Louis Pilfold](https://github.com/lpil))
646646+647647+- Fixed a bug where specific combinations of options in bit array segments would
648648+ not be allowed on the JavaScript target.
649649+ ([Surya Rose](https://github.com/GearsDatapacks))
650650+651651+- Fixed a bug where invalid code would be generated for `let assert` in some
652652+ cases on the JavaScript target.
653653+ ([Surya Rose](https://github.com/GearsDatapacks))
654654+655655+- Fixed a bug where using the prelude `Ok` and `Error` values in a qualified
656656+ fashion could cause a conflict with user-defined `Ok` and `Error` values when
657657+ generating code on the JavaScript target.
658658+ ([Surya Rose](https://github.com/GearsDatapacks))
659659+660660+- Fixed a bug where the "Import module" code action would suggest importing
661661+ internal modules from other packages.
662662+ ([Surya Rose](https://github.com/GearsDatapacks))
663663+664664+- Fixed a bug where the language server would not rename variables defined in
665665+ alternative patterns.
666666+ ([Surya Rose](https://github.com/GearsDatapacks))
667667+668668+- Fixed a bug where trying to rename a type or value from the Gleam prelude
669669+ would result in invalid code.
670670+ ([Surya Rose](https://github.com/GearsDatapacks))
671671+672672+- Fixed a bug where the generated documentation would not be formatted properly.
673673+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
674674+675675+- Fixed a bug where the language server wouldn't allow you to jump to the
676676+ definition of a record from a record update expression.
677677+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
678678+679679+- Fixed a bug where the language server would allow using the "extract variable"
680680+ code action on variables used in record updates.
681681+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
682682+683683+- Fixed a bug where a record pattern with a spread `..` would not be formatted
684684+ properly.
685685+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
686686+687687+- Fixed a bug where fields of custom types named `prototype` would not be
688688+ properly escaped on the JavaScript target.
689689+ ([Surya Rose](https://github.com/GearsDatapacks))
690690+691691+## v1.11.1 - 2025-06-05
692692+693693+### Compiler
694694+695695+- The displaying of internal types in HTML documentation has been improved.
696696+ ([Louis Pilfold](https://github.com/lpil))
697697+698698+- A warning is now emitted when the same module is imported
699699+ multiple times into the same module with different aliases.
700700+ ([Louis Pilfold](https://github.com/lpil))
701701+702702+### Bug fixes
703703+704704+- Fixed a bug where a bit array segment matching on a floating point number
705705+ would match with `NaN` or `Infinity` on the JavaScript target.
706706+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))