···11# Changelog
2233-## v1.4.0 - 2024-08-02
44-55-### Bug Fixes
66-77-- Fixed a bug where pipe function arity errors could have an incorrect error
88- message.
99- ([sobolevn](https://github.com/sobolevn))
1010-1111-- Fixed a bug where the case of type parameters would not be checked.
1212- ([Surya Rose](https://github.com/gearsdatapacks))
1313-1414-- Fixed a bug where the language server would still show completions when inside
1515- a comment.
1616- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
1717-1818-## v1.4.0-rc1 - 2024-07-29
33+## Unreleased
194205### Build tool
2162222-- `gleam docs build` now takes an optional `--target` flag to specify the target
2323- platform for the generated documentation.
2424- ([Jiangda Wang](https://github.com/frank-iii))
2525-2626-- Warnings are now emitted each time the project is built, even if the module
2727- the warnings originated from were loaded from the cache rather than
2828- recompiling.
2929- ([Louis Pilfold](https://github.com/lpil))
3030-317### Compiler
3283333-- Labelled arguments can now use the label shorthand syntax.
3434- This means that when you're passing a variable as a labelled argument and it
3535- happens to have the same name as the label, you can omit the variable name:
3636-3737- ```gleam
3838- pub fn date(day day: Int, month month: Month, year year: Year) -> Date {
3939- todo
4040- }
4141-4242- pub fn main() {
4343- let day = 11
4444- let month = October
4545- let year = 1998
4646-4747- date(year:, month:, day:)
4848- // This is the same as writing
4949- // date(year: year, month: month, day: day)
5050- }
5151- ```
5252-5353- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
5454-5555-- Labelled pattern variables can now use the label shorthand syntax.
5656- This means that when you're pattern matching on a record constructor and
5757- binding its labelled fields to variables that happen to have the same name,
5858- you can omit the variable name:
5959-6060- ```gleam
6161- pub type Date
6262- Date(day: Int, month: Month, year: Year)
6363- }
6464-6565- pub fn main() {
6666- case Date(11, October, 1998) {
6767- Date(year:, month:, day:) -> todo
6868- // This is the same as writing
6969- // Date(year: year, month: month, day: day) -> todo
7070- }
7171-7272- }
7373- ```
7474-7575- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
7676-7777-- The warning for the deprecated `[..]` pattern has been improved.
7878- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
7979-8080-- Record accessors are now fault tolerant. This means an invalid label can be
8181- properly detected and won't invalidate the rest of the expression.
8282- ([Ameen Radwan](https://github.com/Acepie))
8383-8484-- Erlang type spec generation has been improved to avoid new warnings emitted in
8585- OTP27.
8686- ([Damir Vandic](https://github.com/dvic))
8787-8888-- Error messages for invalid record constructors now contain a restructured
8989- example of what the user likely intended. This is especially helpful for
9090- users coming from other languages, like Rust or Go.
9191-9292- For example, provided a User type:
9393-9494- ```gleam
9595- pub type User {
9696- name: String
9797- }
9898- ```
9999-100100- The compiler errors with the following message:
101101-102102- ```
103103- error: Syntax error
104104- ┌─ /src/parse/error.gleam:3:5
105105- │
106106- 3 │ name: String,
107107- │ ^^^^ I was not expecting this
108108-109109- Each custom type variant must have a constructor:
110110-111111- pub type User {
112112- User(
113113- name: String,
114114- )
115115- }
116116- ```
117117-118118- ([Rahul D. Ghosal](https://github.com/rdghosal))
119119-120120-- The `<>` string concatenation operator can now be used in constant
121121- expressions.
122122- ([Thomas](https://github.com/DeviousStoat))
123123-124124-- Function calls are now fault tolerant. This means that errors in the function
125125- call arguments won't stop the rest of the call from being analysed.
126126- ([Ameen Radwan](https://github.com/Acepie))
127127-128128-- The error message presented when a function is called in a guard has been
129129- improved.
130130- ([Thomas](https://github.com/DeviousStoat))
131131-132132-- Case expressions are now fault tolerant. This means an subject, pattern,
133133- guard, or then body can be properly detected and won't invalidate the rest
134134- of the expression.
135135- ([Ameen Radwan](https://github.com/Acepie))
136136-137137-- Documentation comments that come before a regular comment are no longer
138138- clumped together with the documentation of the following definition.
139139- Now commenting out a definition won't result in its documentation merging with
140140- the following one's.
141141-142142- ```gleam
143143- /// This doc comment will be ignored!
144144- // a commented definition
145145- // fn wibble() {}
146146-147147- /// Wibble's documentation.
148148- fn wibble() { todo }
149149- ```
150150-151151- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
152152-153153-- The `little` and `big` endianness options, the `signed` and `unsigned` integer
154154- options, and sized floats (32-bit and 64-bit), can now be used in bit array
155155- expressions and patterns on the JavaScript target.
156156- ([Richard Viney](https://github.com/richard-viney))
157157-158158-- The `utf8` option can now be used with constant strings in bit array patterns
159159- on the JavaScript target.
160160- ([Richard Viney](https://github.com/richard-viney))
161161-1629### Formatter
16310164164-- The formatter will no longer move a documentation comment below a regular
165165- comment following it. This snippet of code is left as it is by the formatter:
166166-167167- ```gleam
168168- /// This doc comment will be ignored!
169169- // a commented definition
170170- // fn wibble() {}
171171-172172- /// Wibble's documentation.
173173- fn wibble() {
174174- todo
175175- }
176176- ```
177177-178178- While previously all documentation comments would be merged together into one,
179179- ignoring the regular comment separating them:
180180-181181- ```gleam
182182- // a commented definition
183183- // fn wibble() {}
184184-185185- /// This doc comment will be ignored!
186186- /// Wibble's documentation.
187187- fn wibble() {
188188- todo
189189- }
190190- ```
191191-192192- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
193193-19411### Language Server
19512196196-- The language server can now show completions for fields if a record access is
197197- being attempted.
198198- ([Ameen Radwan](https://github.com/Acepie))
199199-200200-- The language server will now insert a blank line before the first statement
201201- when inserting a new import and there are no other imports at the top of the
202202- module.
203203- ([Zhomart Mukhamejanov](https://github.com/Zhomart))
204204-205205-- The language server now suggests a code a action to rename variables, types
206206- and functions when they don't match the Gleam naming requirements:
207207-208208- ```gleam
209209- let myNumber = 10
210210- ```
211211-212212- Becomes:
213213-214214- ```gleam
215215- let my_number = 10
216216- ```
217217-218218- ([Surya Rose](https://github.com/gearsdatapacks))
219219-220220-- The language server can now suggest a code action to convert `let assert` into
221221- a case expression:
222222-223223- ```gleam
224224- let assert Ok(value) = get_result()
225225- ```
226226-227227- Becomes:
228228-229229- ```gleam
230230- let value = case get_result() {
231231- Ok(value) -> value
232232- _ -> panic
233233- }
234234- ```
235235-236236- ([Surya Rose](https://github.com/gearsdatapacks))
237237-238238-- The language server can now show signature help when writing functions.
239239- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
240240-241241-- The language server now supports listing document symbols, such as functions
242242- and constants, for the current Gleam file.
243243- ([PgBiel](https://github.com/PgBiel))
244244-245245-- The language server can now suggest a code action to automatically use
246246- shorthand labels where possible:
247247-248248- ```gleam
249249- case date {
250250- Day(day: day, month: month, year: year) -> todo
251251- }
252252- ```
253253-254254- Becomes:
255255-256256- ```gleam
257257- case date {
258258- Day(day:, month:, year:) -> todo
259259- }
260260- ```
261261-262262- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
263263-264264-- The language server can now show completions for labels when writing a
265265- function call or record construction.
266266- ([Ameen Radwan](https://github.com/Acepie))
267267-268268-- The language server can now suggest a code action to fill in the labels of a
269269- function call:
270270-271271- ```gleam
272272- pub type Date {
273273- Date(year: Int, month: Int, day: Int)
274274- }
275275-276276- pub fn main() {
277277- Date()
278278- }
279279- ```
280280-281281- Becomes:
282282-283283- ```gleam
284284- pub type Date {
285285- Date(year: Int, month: Int, day: Int)
286286- }
287287-288288- pub fn main() {
289289- Date(year: todo, month: todo, day: todo)
290290- }
291291- ```
292292-293293- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
294294-295295-- Completions are now sorted by priority based on why the completion is in the
296296- list. This means that more specific completions like labels and local
297297- definitions will be shown before more broad completions like functions from a
298298- not yet imported module.
299299- ([Ameen Radwan](https://github.com/Acepie))
300300-30113### Bug Fixes
302302-303303-- Functions, types and constructors named `module_info` are now escaped
304304- in generated Erlang code to avoid conflicts with the builtin
305305- `module_info/0` and `module_info/1` functions.
306306- ([Juraj Petráš](https://github.com/Hackder))
307307-308308-- Fixed formatting of comments at the start of a case branch.
309309- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
310310-311311-- Fixed a bug where a private type could be leaked from an internal module.
312312- ([Ameen Radwan](https://github.com/Acepie))
313313-314314-- Fixed a bug where certain binops would not wrap their arguments properly
315315- thus generating invalid JavaScript.
316316- ([Ameen Radwan](https://github.com/Acepie))
317317-318318-- Fixed formatting of function definitions marked as `@internal`
319319- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
320320-321321-- Fixed a bug where importing a record constructor in an unqualified fashion and
322322- aliasing it and then using it in a case guard expression would generate
323323- invalid JavaScript.
324324- ([PgBiel](https://github.com/PgBiel))
325325-326326-## v1.3.2 - 2024-07-11
327327-328328-### Language Server
329329-330330-- The language server no longer shows completions when inside a literal string.
331331- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
332332-333333-### Bug Fixes
334334-335335-- Fixed a bug where the compiler would report errors for duplicate `@external`
336336- attributes with inconsistent spans between Erlang and JavaScript.
337337- ([Connor Szczepaniak](https://github.com/cszczepaniak))
338338-339339-- Fixed a bug where `gleam add` would fail to parse version specifiers
340340- correctly.
341341- ([Louis Pilfold](https://github.com/lpil))
342342-343343-- Fixed a bug where single clause case expressions could generate JavaScript
344344- code with incorrectly rewritten JavaScript variable names.
345345- ([Louis Pilfold](https://github.com/lpil))
346346-347347-## v1.3.1 - 2024-07-10
348348-349349-### Bug Fixes
350350-351351-- Fixes a bug with import cycle detection when there is more than 2 imports in
352352- the cycle.
353353- ([Ameen Radwan](https://github.com/Acepie))
···11+# Changelog
22+33+## v1.4.0 - 2024-08-02
44+55+### Bug Fixes
66+77+- Fixed a bug where pipe function arity errors could have an incorrect error
88+ message.
99+ ([sobolevn](https://github.com/sobolevn))
1010+1111+- Fixed a bug where the case of type parameters would not be checked.
1212+ ([Surya Rose](https://github.com/gearsdatapacks))
1313+1414+- Fixed a bug where the language server would still show completions when inside
1515+ a comment.
1616+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
1717+1818+## v1.4.0-rc1 - 2024-07-29
1919+2020+### Build tool
2121+2222+- `gleam docs build` now takes an optional `--target` flag to specify the target
2323+ platform for the generated documentation.
2424+ ([Jiangda Wang](https://github.com/frank-iii))
2525+2626+- Warnings are now emitted each time the project is built, even if the module
2727+ the warnings originated from were loaded from the cache rather than
2828+ recompiling.
2929+ ([Louis Pilfold](https://github.com/lpil))
3030+3131+### Compiler
3232+3333+- Labelled arguments can now use the label shorthand syntax.
3434+ This means that when you're passing a variable as a labelled argument and it
3535+ happens to have the same name as the label, you can omit the variable name:
3636+3737+ ```gleam
3838+ pub fn date(day day: Int, month month: Month, year year: Year) -> Date {
3939+ todo
4040+ }
4141+4242+ pub fn main() {
4343+ let day = 11
4444+ let month = October
4545+ let year = 1998
4646+4747+ date(year:, month:, day:)
4848+ // This is the same as writing
4949+ // date(year: year, month: month, day: day)
5050+ }
5151+ ```
5252+5353+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
5454+5555+- Labelled pattern variables can now use the label shorthand syntax.
5656+ This means that when you're pattern matching on a record constructor and
5757+ binding its labelled fields to variables that happen to have the same name,
5858+ you can omit the variable name:
5959+6060+ ```gleam
6161+ pub type Date
6262+ Date(day: Int, month: Month, year: Year)
6363+ }
6464+6565+ pub fn main() {
6666+ case Date(11, October, 1998) {
6767+ Date(year:, month:, day:) -> todo
6868+ // This is the same as writing
6969+ // Date(year: year, month: month, day: day) -> todo
7070+ }
7171+7272+ }
7373+ ```
7474+7575+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
7676+7777+- The warning for the deprecated `[..]` pattern has been improved.
7878+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
7979+8080+- Record accessors are now fault tolerant. This means an invalid label can be
8181+ properly detected and won't invalidate the rest of the expression.
8282+ ([Ameen Radwan](https://github.com/Acepie))
8383+8484+- Erlang type spec generation has been improved to avoid new warnings emitted in
8585+ OTP27.
8686+ ([Damir Vandic](https://github.com/dvic))
8787+8888+- Error messages for invalid record constructors now contain a restructured
8989+ example of what the user likely intended. This is especially helpful for
9090+ users coming from other languages, like Rust or Go.
9191+9292+ For example, provided a User type:
9393+9494+ ```gleam
9595+ pub type User {
9696+ name: String
9797+ }
9898+ ```
9999+100100+ The compiler errors with the following message:
101101+102102+ ```
103103+ error: Syntax error
104104+ ┌─ /src/parse/error.gleam:3:5
105105+ │
106106+ 3 │ name: String,
107107+ │ ^^^^ I was not expecting this
108108+109109+ Each custom type variant must have a constructor:
110110+111111+ pub type User {
112112+ User(
113113+ name: String,
114114+ )
115115+ }
116116+ ```
117117+118118+ ([Rahul D. Ghosal](https://github.com/rdghosal))
119119+120120+- The `<>` string concatenation operator can now be used in constant
121121+ expressions.
122122+ ([Thomas](https://github.com/DeviousStoat))
123123+124124+- Function calls are now fault tolerant. This means that errors in the function
125125+ call arguments won't stop the rest of the call from being analysed.
126126+ ([Ameen Radwan](https://github.com/Acepie))
127127+128128+- The error message presented when a function is called in a guard has been
129129+ improved.
130130+ ([Thomas](https://github.com/DeviousStoat))
131131+132132+- Case expressions are now fault tolerant. This means an subject, pattern,
133133+ guard, or then body can be properly detected and won't invalidate the rest
134134+ of the expression.
135135+ ([Ameen Radwan](https://github.com/Acepie))
136136+137137+- Documentation comments that come before a regular comment are no longer
138138+ clumped together with the documentation of the following definition.
139139+ Now commenting out a definition won't result in its documentation merging with
140140+ the following one's.
141141+142142+ ```gleam
143143+ /// This doc comment will be ignored!
144144+ // a commented definition
145145+ // fn wibble() {}
146146+147147+ /// Wibble's documentation.
148148+ fn wibble() { todo }
149149+ ```
150150+151151+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
152152+153153+- The `little` and `big` endianness options, the `signed` and `unsigned` integer
154154+ options, and sized floats (32-bit and 64-bit), can now be used in bit array
155155+ expressions and patterns on the JavaScript target.
156156+ ([Richard Viney](https://github.com/richard-viney))
157157+158158+- The `utf8` option can now be used with constant strings in bit array patterns
159159+ on the JavaScript target.
160160+ ([Richard Viney](https://github.com/richard-viney))
161161+162162+### Formatter
163163+164164+- The formatter will no longer move a documentation comment below a regular
165165+ comment following it. This snippet of code is left as it is by the formatter:
166166+167167+ ```gleam
168168+ /// This doc comment will be ignored!
169169+ // a commented definition
170170+ // fn wibble() {}
171171+172172+ /// Wibble's documentation.
173173+ fn wibble() {
174174+ todo
175175+ }
176176+ ```
177177+178178+ While previously all documentation comments would be merged together into one,
179179+ ignoring the regular comment separating them:
180180+181181+ ```gleam
182182+ // a commented definition
183183+ // fn wibble() {}
184184+185185+ /// This doc comment will be ignored!
186186+ /// Wibble's documentation.
187187+ fn wibble() {
188188+ todo
189189+ }
190190+ ```
191191+192192+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
193193+194194+### Language Server
195195+196196+- The language server can now show completions for fields if a record access is
197197+ being attempted.
198198+ ([Ameen Radwan](https://github.com/Acepie))
199199+200200+- The language server will now insert a blank line before the first statement
201201+ when inserting a new import and there are no other imports at the top of the
202202+ module.
203203+ ([Zhomart Mukhamejanov](https://github.com/Zhomart))
204204+205205+- The language server now suggests a code a action to rename variables, types
206206+ and functions when they don't match the Gleam naming requirements:
207207+208208+ ```gleam
209209+ let myNumber = 10
210210+ ```
211211+212212+ Becomes:
213213+214214+ ```gleam
215215+ let my_number = 10
216216+ ```
217217+218218+ ([Surya Rose](https://github.com/gearsdatapacks))
219219+220220+- The language server can now suggest a code action to convert `let assert` into
221221+ a case expression:
222222+223223+ ```gleam
224224+ let assert Ok(value) = get_result()
225225+ ```
226226+227227+ Becomes:
228228+229229+ ```gleam
230230+ let value = case get_result() {
231231+ Ok(value) -> value
232232+ _ -> panic
233233+ }
234234+ ```
235235+236236+ ([Surya Rose](https://github.com/gearsdatapacks))
237237+238238+- The language server can now show signature help when writing functions.
239239+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
240240+241241+- The language server now supports listing document symbols, such as functions
242242+ and constants, for the current Gleam file.
243243+ ([PgBiel](https://github.com/PgBiel))
244244+245245+- The language server can now suggest a code action to automatically use
246246+ shorthand labels where possible:
247247+248248+ ```gleam
249249+ case date {
250250+ Day(day: day, month: month, year: year) -> todo
251251+ }
252252+ ```
253253+254254+ Becomes:
255255+256256+ ```gleam
257257+ case date {
258258+ Day(day:, month:, year:) -> todo
259259+ }
260260+ ```
261261+262262+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
263263+264264+- The language server can now show completions for labels when writing a
265265+ function call or record construction.
266266+ ([Ameen Radwan](https://github.com/Acepie))
267267+268268+- The language server can now suggest a code action to fill in the labels of a
269269+ function call:
270270+271271+ ```gleam
272272+ pub type Date {
273273+ Date(year: Int, month: Int, day: Int)
274274+ }
275275+276276+ pub fn main() {
277277+ Date()
278278+ }
279279+ ```
280280+281281+ Becomes:
282282+283283+ ```gleam
284284+ pub type Date {
285285+ Date(year: Int, month: Int, day: Int)
286286+ }
287287+288288+ pub fn main() {
289289+ Date(year: todo, month: todo, day: todo)
290290+ }
291291+ ```
292292+293293+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
294294+295295+- Completions are now sorted by priority based on why the completion is in the
296296+ list. This means that more specific completions like labels and local
297297+ definitions will be shown before more broad completions like functions from a
298298+ not yet imported module.
299299+ ([Ameen Radwan](https://github.com/Acepie))
300300+301301+### Bug Fixes
302302+303303+- Functions, types and constructors named `module_info` are now escaped
304304+ in generated Erlang code to avoid conflicts with the builtin
305305+ `module_info/0` and `module_info/1` functions.
306306+ ([Juraj Petráš](https://github.com/Hackder))
307307+308308+- Fixed formatting of comments at the start of a case branch.
309309+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
310310+311311+- Fixed a bug where a private type could be leaked from an internal module.
312312+ ([Ameen Radwan](https://github.com/Acepie))
313313+314314+- Fixed a bug where certain binops would not wrap their arguments properly
315315+ thus generating invalid JavaScript.
316316+ ([Ameen Radwan](https://github.com/Acepie))
317317+318318+- Fixed formatting of function definitions marked as `@internal`
319319+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
320320+321321+- Fixed a bug where importing a record constructor in an unqualified fashion and
322322+ aliasing it and then using it in a case guard expression would generate
323323+ invalid JavaScript.
324324+ ([PgBiel](https://github.com/PgBiel))
325325+326326+## v1.3.2 - 2024-07-11
327327+328328+### Language Server
329329+330330+- The language server no longer shows completions when inside a literal string.
331331+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
332332+333333+### Bug Fixes
334334+335335+- Fixed a bug where the compiler would report errors for duplicate `@external`
336336+ attributes with inconsistent spans between Erlang and JavaScript.
337337+ ([Connor Szczepaniak](https://github.com/cszczepaniak))
338338+339339+- Fixed a bug where `gleam add` would fail to parse version specifiers
340340+ correctly.
341341+ ([Louis Pilfold](https://github.com/lpil))
342342+343343+- Fixed a bug where single clause case expressions could generate JavaScript
344344+ code with incorrectly rewritten JavaScript variable names.
345345+ ([Louis Pilfold](https://github.com/lpil))
346346+347347+## v1.3.1 - 2024-07-10
348348+349349+### Bug Fixes
350350+351351+- Fixes a bug with import cycle detection when there is more than 2 imports in
352352+ the cycle.
353353+ ([Ameen Radwan](https://github.com/Acepie))