···11# Changelog
2233-Dedicated to the memory of Len Pilfold.
44-55-## v1.8.0 - 2025-02-07
66-77-## v1.8.0-rc1 - 2025-02-03
33+## Unreleased
8495### Compiler
1061111-- Pipelines are now fault tolerant. A type error in the middle of a pipeline
1212- won't stop the compiler from figuring out the types of the remaining pieces,
1313- enabling the language server to show better suggestions for incomplete pipes.
1414- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
1515-1616-- Improved code generation for blocks in tail position on the Javascript target.
1717- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
1818-1919-- Function documentation comments and module documentation comments are now
2020- included in the generated Erlang code and can be browsed from the Erlang
2121- shell starting from OTP27.
2222- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
2323-2424-- Parsing of `case` expressions is now fault tolerant. If a `case` expressions
2525- is missing its body, the compiler can still perform type inference. This also
2626- allows the Language Server to provide completion hints for `case` subjects.
2727- ([Surya Rose](https://github.com/GearsDatapacks))
2828-2929-- The compiler can now suggest to wrap a value in an `Ok` or `Error` if that can
3030- solve a type mismatch error:
3131-3232- ```gleam
3333- pub fn greet_logged_user() {
3434- use <- bool.guard(when: !logged_in, return: Error(Nil))
3535- "Hello!"
3636- }
3737- ```
3838-3939- Results in the following error:
4040-4141- ```txt
4242- error: Type mismatch
4343- ┌─ /main.gleam:7:3
4444- │
4545- 7 │ "Hello!"
4646- │ ^^^^^^^^ Did you mean to wrap this in an `Ok`?
4747-4848- Expected type:
4949-5050- Result(a, Nil)
5151-5252- Found type:
5353-5454- String
5555- ```
5656-5757- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
5858-5959-- The compiler now shows an improved error message when using an unknown type as a
6060- variable name
6161-6262- ```txt
6363- error: Unknown variable
6464- ┌─ /src/one/two.gleam:4:3
6565- │
6666- 4 │ X
6767- │ ^
6868- The custom type variant constructor `X` is not in scope here.
6969- ```
7070-7171- ([Roeeeee](https://github.com/5c077m4n))
7272-7373-- Erlang `file` module attributes now use paths relative to the root.
7474- ([Kasim](https://github.com/oneness))
7575-7676-### Build tool
7777-7878-- `gleam new` now has refined project name validation - rather than failing on
7979- invalid project names, it suggests a valid alternative and prompts for
8080- confirmation to use it.
8181- ([Diemo Gebhardt](https://github.com/diemogebhardt))
8282-8383-- `gleam docs build` generated documentation site now focuses the search input
8484- when "Cmd/Ctrl + K", "s" or "/" is pressed.
8585- ([Sambit Sahoo](https://github.com/soulsam480))
8686-8787-- `gleam deps` now supports `tree` operation that lists the dependency tree.
8888-8989- ```markdown
9090- Usage: gleam deps tree [OPTIONS]
9191-9292- Options:
9393- -p, --package <PACKAGE> Package to be used as the root of the tree
9494- -i, --invert <PACKAGE> Invert the tree direction and focus on the given package
9595- -h, --help Print help
9696- ```
9797-9898- For example, if the root project (`project_a`) depends on `package_b` and
9999- `package_c`, and `package_c` also depends on `package_b`, the output will be:
100100-101101-102102- ```markdown
103103- $ gleam deps tree
104104-105105- project_a v1.0.0
106106- ├── package_b v0.52.0
107107- └── package_c v1.2.0
108108- └── package_b v0.52.0
109109-110110- $ gleam deps tree --package package_c
111111-112112- package_c v1.2.0
113113- └── package_b v0.52.0
114114-115115- $ gleam deps tree --invert package_b
116116-117117- package_b v0.52.0
118118- ├── package_c v1.2.0
119119- │ └── project_a v1.0.0
120120- └── project_a v1.0.0
121121-122122- ```
123123-124124- ([Ramkarthik Krishnamurthy](https://github.com/ramkarthik))
125125-126126-- The build tool now checks for modules that would collide with the new Erlang
127127- `json` module in addition to the existing Erlang modules it already checked
128128- for.
129129- ([Louis Pilfold](https://github.com/lpil))
130130-1317### Language server
1328133133-- The language server can now generate the definition of functions that do not
134134- exist in the current file. For example if I write the following piece of code:
135135-136136- ```gleam
137137- import gleam/io
138138-139139- pub type Pokemon {
140140- Pokemon(pokedex_number: Int, name: String)
141141- }
142142-143143- pub fn main() {
144144- io.println(to_string(pokemon))
145145- // ^ If you put your cursor over this function that is
146146- // not implemented yet
147147- }
148148- ```
149149-150150- Triggering the "generate function" code action, the language server will
151151- generate the following function for you:
152152-153153- ```gleam
154154- fn to_string(pokemon: Pokemon) -> String {
155155- todo
156156- }
157157- ```
158158-159159- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
160160-161161-- The language server can now fill in the labels of any function call, even when
162162- only some of the arguments are provided. For example:
163163-164164- ```gleam
165165- import gleam/string
166166-167167- pub fn main() {
168168- string.replace("wibble")
169169- }
170170- ```
171171-172172- Will be completed to:
173173-174174- ```gleam
175175- import gleam/string
176176-177177- pub fn main() {
178178- string.replace("wibble", each: todo, with: todo)
179179- }
180180- ```
181181-182182- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
183183-184184-- The language server now suggests a code action to pattern match on a
185185- function's argument. For example:
186186-187187- ```gleam
188188- pub type Pokemon {
189189- Pokemon(pokedex_number: Int, name: String)
190190- }
191191-192192- pub fn to_string(pokemon: Pokemon) {
193193- // ^ If you put your cursor over the argument
194194- todo
195195- }
196196- ```
197197-198198- Triggering the code action on the `pokemon` argument will generate the
199199- following code for you:
200200-201201- ```gleam
202202- pub type Pokemon {
203203- Pokemon(pokedex_number: Int, name: String)
204204- }
205205-206206- pub fn to_string(pokemon: Pokemon) {
207207- let Pokemon(pokedex_number:, name:) = pokemon
208208- todo
209209- }
210210- ```
211211-212212- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
213213-214214-- The language server now suggests a code action to pattern match on a variable.
215215- For example:
216216-217217- ```gleam
218218- pub fn main() {
219219- let result = list.first(a_list)
220220- // ^ If you put your cursor over the variable
221221- todo
222222- }
223223- ```
224224-225225- Triggering the code action on the `result` variable will generate the
226226- following code for you:
227227-228228- ```gleam
229229- pub fn main() {
230230- let result = list.first(a_list)
231231- case result {
232232- Ok(value) -> todo
233233- Error(value) -> todo
234234- }
235235- todo
236236- }
237237- ```
238238-239239- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
240240-241241-- When generating functions or variables, the language server can now pick
242242- better names using the type of the code it's generating.
243243- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
244244-245245-- The Language Server now provides the ability to rename local variables.
246246- For example:
247247-248248- ```gleam
249249- pub fn main() {
250250- let wibble = 10
251251- // ^ If you put your cursor here, and trigger a rename
252252- wibble + 1
253253- }
254254- ```
255255-256256- Triggering a rename and entering `my_number` results in this code:
257257-258258-259259- ```gleam
260260- pub fn main() {
261261- let my_number = 10
262262- my_number + 1
263263- }
264264- ```
265265-266266- ([Surya Rose](https://github.com/GearsDatapacks))
267267-268268-- `Unqualify` Action now get triggered when hovering over the module name
269269- for record value constructor.
270270- For example:
271271-272272- ```gleam
273273- pub fn main() {
274274- let my_option = option.Some(1)
275275- // ^ would trigger "Unqualify option.Some"
276276- }
277277- ```
278278- ([Jiangda Wang](https://github.com/Frank-III))
279279-2809### Formatter
2811028211### Bug fixes
283283-284284-- Fixed a bug where the "convert from use" code action would generate invalid
285285- code for use expressions ending with a trailing comma.
286286- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
287287-288288-- Fixed a bug where floats outside of Erlang's floating point range were not
289289- causing errors.
290290- ([shayan](https://github.com/massivefermion))
291291-292292-- Fixed a bug where build tool could fail to add new dependencies when
293293- dependencies with optional dependencies are present in the manifest.
294294- ([Louis Pilfold](https://github.com/lpil))
295295-296296-- Fixed a bug where a block expression containing a singular record update would
297297- produce invalid erlang.
298298- ([yoshi](https://github.com/joshi-monster))
299299-300300-- Fixed a typo in the error message when trying to import a test module into an
301301- application module.
302302- ([John Strunk](https://github.com/jrstrunk))
303303-304304-- Fixed a bug where the "Extract variable" code action would erroneously extract
305305- a pipeline step as a variable.
306306- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
307307-308308-- Fixed a bug where variables bound in `let assert` assignments would be allowed
309309- to be used in the custom panic message.
310310- ([Surya Rose](https://github.com/GearsDatapacks))
···11+# Changelog
22+33+Dedicated to the memory of Len Pilfold.
44+55+## v1.8.0 - 2025-02-07
66+77+## v1.8.0-rc1 - 2025-02-03
88+99+### Compiler
1010+1111+- Pipelines are now fault tolerant. A type error in the middle of a pipeline
1212+ won't stop the compiler from figuring out the types of the remaining pieces,
1313+ enabling the language server to show better suggestions for incomplete pipes.
1414+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
1515+1616+- Improved code generation for blocks in tail position on the Javascript target.
1717+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
1818+1919+- Function documentation comments and module documentation comments are now
2020+ included in the generated Erlang code and can be browsed from the Erlang
2121+ shell starting from OTP27.
2222+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
2323+2424+- Parsing of `case` expressions is now fault tolerant. If a `case` expressions
2525+ is missing its body, the compiler can still perform type inference. This also
2626+ allows the Language Server to provide completion hints for `case` subjects.
2727+ ([Surya Rose](https://github.com/GearsDatapacks))
2828+2929+- The compiler can now suggest to wrap a value in an `Ok` or `Error` if that can
3030+ solve a type mismatch error:
3131+3232+ ```gleam
3333+ pub fn greet_logged_user() {
3434+ use <- bool.guard(when: !logged_in, return: Error(Nil))
3535+ "Hello!"
3636+ }
3737+ ```
3838+3939+ Results in the following error:
4040+4141+ ```txt
4242+ error: Type mismatch
4343+ ┌─ /main.gleam:7:3
4444+ │
4545+ 7 │ "Hello!"
4646+ │ ^^^^^^^^ Did you mean to wrap this in an `Ok`?
4747+4848+ Expected type:
4949+5050+ Result(a, Nil)
5151+5252+ Found type:
5353+5454+ String
5555+ ```
5656+5757+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
5858+5959+- The compiler now shows an improved error message when using an unknown type as a
6060+ variable name
6161+6262+ ```txt
6363+ error: Unknown variable
6464+ ┌─ /src/one/two.gleam:4:3
6565+ │
6666+ 4 │ X
6767+ │ ^
6868+ The custom type variant constructor `X` is not in scope here.
6969+ ```
7070+7171+ ([Roeeeee](https://github.com/5c077m4n))
7272+7373+- Erlang `file` module attributes now use paths relative to the root.
7474+ ([Kasim](https://github.com/oneness))
7575+7676+### Build tool
7777+7878+- `gleam new` now has refined project name validation - rather than failing on
7979+ invalid project names, it suggests a valid alternative and prompts for
8080+ confirmation to use it.
8181+ ([Diemo Gebhardt](https://github.com/diemogebhardt))
8282+8383+- `gleam docs build` generated documentation site now focuses the search input
8484+ when "Cmd/Ctrl + K", "s" or "/" is pressed.
8585+ ([Sambit Sahoo](https://github.com/soulsam480))
8686+8787+- `gleam deps` now supports `tree` operation that lists the dependency tree.
8888+8989+ ```markdown
9090+ Usage: gleam deps tree [OPTIONS]
9191+9292+ Options:
9393+ -p, --package <PACKAGE> Package to be used as the root of the tree
9494+ -i, --invert <PACKAGE> Invert the tree direction and focus on the given package
9595+ -h, --help Print help
9696+ ```
9797+9898+ For example, if the root project (`project_a`) depends on `package_b` and
9999+ `package_c`, and `package_c` also depends on `package_b`, the output will be:
100100+101101+102102+ ```markdown
103103+ $ gleam deps tree
104104+105105+ project_a v1.0.0
106106+ ├── package_b v0.52.0
107107+ └── package_c v1.2.0
108108+ └── package_b v0.52.0
109109+110110+ $ gleam deps tree --package package_c
111111+112112+ package_c v1.2.0
113113+ └── package_b v0.52.0
114114+115115+ $ gleam deps tree --invert package_b
116116+117117+ package_b v0.52.0
118118+ ├── package_c v1.2.0
119119+ │ └── project_a v1.0.0
120120+ └── project_a v1.0.0
121121+122122+ ```
123123+124124+ ([Ramkarthik Krishnamurthy](https://github.com/ramkarthik))
125125+126126+- The build tool now checks for modules that would collide with the new Erlang
127127+ `json` module in addition to the existing Erlang modules it already checked
128128+ for.
129129+ ([Louis Pilfold](https://github.com/lpil))
130130+131131+### Language server
132132+133133+- The language server can now generate the definition of functions that do not
134134+ exist in the current file. For example if I write the following piece of code:
135135+136136+ ```gleam
137137+ import gleam/io
138138+139139+ pub type Pokemon {
140140+ Pokemon(pokedex_number: Int, name: String)
141141+ }
142142+143143+ pub fn main() {
144144+ io.println(to_string(pokemon))
145145+ // ^ If you put your cursor over this function that is
146146+ // not implemented yet
147147+ }
148148+ ```
149149+150150+ Triggering the "generate function" code action, the language server will
151151+ generate the following function for you:
152152+153153+ ```gleam
154154+ fn to_string(pokemon: Pokemon) -> String {
155155+ todo
156156+ }
157157+ ```
158158+159159+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
160160+161161+- The language server can now fill in the labels of any function call, even when
162162+ only some of the arguments are provided. For example:
163163+164164+ ```gleam
165165+ import gleam/string
166166+167167+ pub fn main() {
168168+ string.replace("wibble")
169169+ }
170170+ ```
171171+172172+ Will be completed to:
173173+174174+ ```gleam
175175+ import gleam/string
176176+177177+ pub fn main() {
178178+ string.replace("wibble", each: todo, with: todo)
179179+ }
180180+ ```
181181+182182+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
183183+184184+- The language server now suggests a code action to pattern match on a
185185+ function's argument. For example:
186186+187187+ ```gleam
188188+ pub type Pokemon {
189189+ Pokemon(pokedex_number: Int, name: String)
190190+ }
191191+192192+ pub fn to_string(pokemon: Pokemon) {
193193+ // ^ If you put your cursor over the argument
194194+ todo
195195+ }
196196+ ```
197197+198198+ Triggering the code action on the `pokemon` argument will generate the
199199+ following code for you:
200200+201201+ ```gleam
202202+ pub type Pokemon {
203203+ Pokemon(pokedex_number: Int, name: String)
204204+ }
205205+206206+ pub fn to_string(pokemon: Pokemon) {
207207+ let Pokemon(pokedex_number:, name:) = pokemon
208208+ todo
209209+ }
210210+ ```
211211+212212+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
213213+214214+- The language server now suggests a code action to pattern match on a variable.
215215+ For example:
216216+217217+ ```gleam
218218+ pub fn main() {
219219+ let result = list.first(a_list)
220220+ // ^ If you put your cursor over the variable
221221+ todo
222222+ }
223223+ ```
224224+225225+ Triggering the code action on the `result` variable will generate the
226226+ following code for you:
227227+228228+ ```gleam
229229+ pub fn main() {
230230+ let result = list.first(a_list)
231231+ case result {
232232+ Ok(value) -> todo
233233+ Error(value) -> todo
234234+ }
235235+ todo
236236+ }
237237+ ```
238238+239239+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
240240+241241+- When generating functions or variables, the language server can now pick
242242+ better names using the type of the code it's generating.
243243+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
244244+245245+- The Language Server now provides the ability to rename local variables.
246246+ For example:
247247+248248+ ```gleam
249249+ pub fn main() {
250250+ let wibble = 10
251251+ // ^ If you put your cursor here, and trigger a rename
252252+ wibble + 1
253253+ }
254254+ ```
255255+256256+ Triggering a rename and entering `my_number` results in this code:
257257+258258+259259+ ```gleam
260260+ pub fn main() {
261261+ let my_number = 10
262262+ my_number + 1
263263+ }
264264+ ```
265265+266266+ ([Surya Rose](https://github.com/GearsDatapacks))
267267+268268+- `Unqualify` Action now get triggered when hovering over the module name
269269+ for record value constructor.
270270+ For example:
271271+272272+ ```gleam
273273+ pub fn main() {
274274+ let my_option = option.Some(1)
275275+ // ^ would trigger "Unqualify option.Some"
276276+ }
277277+ ```
278278+ ([Jiangda Wang](https://github.com/Frank-III))
279279+280280+### Formatter
281281+282282+### Bug fixes
283283+284284+- Fixed a bug where the "convert from use" code action would generate invalid
285285+ code for use expressions ending with a trailing comma.
286286+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
287287+288288+- Fixed a bug where floats outside of Erlang's floating point range were not
289289+ causing errors.
290290+ ([shayan](https://github.com/massivefermion))
291291+292292+- Fixed a bug where build tool could fail to add new dependencies when
293293+ dependencies with optional dependencies are present in the manifest.
294294+ ([Louis Pilfold](https://github.com/lpil))
295295+296296+- Fixed a bug where a block expression containing a singular record update would
297297+ produce invalid erlang.
298298+ ([yoshi](https://github.com/joshi-monster))
299299+300300+- Fixed a typo in the error message when trying to import a test module into an
301301+ application module.
302302+ ([John Strunk](https://github.com/jrstrunk))
303303+304304+- Fixed a bug where the "Extract variable" code action would erroneously extract
305305+ a pipeline step as a variable.
306306+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
307307+308308+- Fixed a bug where variables bound in `let assert` assignments would be allowed
309309+ to be used in the custom panic message.
310310+ ([Surya Rose](https://github.com/GearsDatapacks))