Skip to content

Commit

Permalink
v1.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Feb 11, 2025
1 parent 593e9f3 commit 7707572
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 331 deletions.
307 changes: 3 additions & 304 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,310 +1,9 @@
# Changelog

Dedicated to the memory of Len Pilfold.

## v1.8.0 - 2025-02-07

## v1.8.0-rc1 - 2025-02-03

### Compiler

- Pipelines are now fault tolerant. A type error in the middle of a pipeline
won't stop the compiler from figuring out the types of the remaining pieces,
enabling the language server to show better suggestions for incomplete pipes.
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- Improved code generation for blocks in tail position on the Javascript target.
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- Function documentation comments and module documentation comments are now
included in the generated Erlang code and can be browsed from the Erlang
shell starting from OTP27.
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- Parsing of `case` expressions is now fault tolerant. If a `case` expressions
is missing its body, the compiler can still perform type inference. This also
allows the Language Server to provide completion hints for `case` subjects.
([Surya Rose](https://github.com/GearsDatapacks))

- The compiler can now suggest to wrap a value in an `Ok` or `Error` if that can
solve a type mismatch error:

```gleam
pub fn greet_logged_user() {
use <- bool.guard(when: !logged_in, return: Error(Nil))
"Hello!"
}
```

Results in the following error:

```txt
error: Type mismatch
┌─ /main.gleam:7:3
7 │ "Hello!"
│ ^^^^^^^^ Did you mean to wrap this in an `Ok`?
Expected type:
Result(a, Nil)
Found type:
String
```

([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- The compiler now shows an improved error message when using an unknown type as a
variable name

```txt
error: Unknown variable
┌─ /src/one/two.gleam:4:3
4 │ X
│ ^
The custom type variant constructor `X` is not in scope here.
```

([Roeeeee](https://github.com/5c077m4n))

- Erlang `file` module attributes now use paths relative to the root.
([Kasim](https://github.com/oneness))

### Build tool

- `gleam new` now has refined project name validation - rather than failing on
invalid project names, it suggests a valid alternative and prompts for
confirmation to use it.
([Diemo Gebhardt](https://github.com/diemogebhardt))

- `gleam docs build` generated documentation site now focuses the search input
when "Cmd/Ctrl + K", "s" or "/" is pressed.
([Sambit Sahoo](https://github.com/soulsam480))

- `gleam deps` now supports `tree` operation that lists the dependency tree.

```markdown
Usage: gleam deps tree [OPTIONS]

Options:
-p, --package <PACKAGE> Package to be used as the root of the tree
-i, --invert <PACKAGE> Invert the tree direction and focus on the given package
-h, --help Print help
```

For example, if the root project (`project_a`) depends on `package_b` and
`package_c`, and `package_c` also depends on `package_b`, the output will be:


```markdown
$ gleam deps tree

project_a v1.0.0
├── package_b v0.52.0
└── package_c v1.2.0
└── package_b v0.52.0

$ gleam deps tree --package package_c

package_c v1.2.0
└── package_b v0.52.0

$ gleam deps tree --invert package_b

package_b v0.52.0
├── package_c v1.2.0
│ └── project_a v1.0.0
└── project_a v1.0.0

```

([Ramkarthik Krishnamurthy](https://github.com/ramkarthik))

- The build tool now checks for modules that would collide with the new Erlang
`json` module in addition to the existing Erlang modules it already checked
for.
([Louis Pilfold](https://github.com/lpil))

### Language server

- The language server can now generate the definition of functions that do not
exist in the current file. For example if I write the following piece of code:

```gleam
import gleam/io
pub type Pokemon {
Pokemon(pokedex_number: Int, name: String)
}
pub fn main() {
io.println(to_string(pokemon))
// ^ If you put your cursor over this function that is
// not implemented yet
}
```

Triggering the "generate function" code action, the language server will
generate the following function for you:

```gleam
fn to_string(pokemon: Pokemon) -> String {
todo
}
```

([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- The language server can now fill in the labels of any function call, even when
only some of the arguments are provided. For example:

```gleam
import gleam/string
pub fn main() {
string.replace("wibble")
}
```

Will be completed to:

```gleam
import gleam/string
pub fn main() {
string.replace("wibble", each: todo, with: todo)
}
```

([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- The language server now suggests a code action to pattern match on a
function's argument. For example:

```gleam
pub type Pokemon {
Pokemon(pokedex_number: Int, name: String)
}
pub fn to_string(pokemon: Pokemon) {
// ^ If you put your cursor over the argument
todo
}
```

Triggering the code action on the `pokemon` argument will generate the
following code for you:

```gleam
pub type Pokemon {
Pokemon(pokedex_number: Int, name: String)
}
pub fn to_string(pokemon: Pokemon) {
let Pokemon(pokedex_number:, name:) = pokemon
todo
}
```

([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- The language server now suggests a code action to pattern match on a variable.
For example:

```gleam
pub fn main() {
let result = list.first(a_list)
// ^ If you put your cursor over the variable
todo
}
```

Triggering the code action on the `result` variable will generate the
following code for you:

```gleam
pub fn main() {
let result = list.first(a_list)
case result {
Ok(value) -> todo
Error(value) -> todo
}
todo
}
```

([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- When generating functions or variables, the language server can now pick
better names using the type of the code it's generating.
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- The Language Server now provides the ability to rename local variables.
For example:

```gleam
pub fn main() {
let wibble = 10
// ^ If you put your cursor here, and trigger a rename
wibble + 1
}
```

Triggering a rename and entering `my_number` results in this code:


```gleam
pub fn main() {
let my_number = 10
my_number + 1
}
```

([Surya Rose](https://github.com/GearsDatapacks))

- `Unqualify` Action now get triggered when hovering over the module name
for record value constructor.
For example:

```gleam
pub fn main() {
let my_option = option.Some(1)
// ^ would trigger "Unqualify option.Some"
}
```
([Jiangda Wang](https://github.com/Frank-III))

### Formatter
## v1.8.1 - 2025-02-11

### Bug fixes

- Fixed a bug where the "convert from use" code action would generate invalid
code for use expressions ending with a trailing comma.
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- Fixed a bug where floats outside of Erlang's floating point range were not
causing errors.
([shayan](https://github.com/massivefermion))

- Fixed a bug where build tool could fail to add new dependencies when
dependencies with optional dependencies are present in the manifest.
- Fixed a metadata caching bug where accessors for opaque types could sometimes
be used in other modules.
([Louis Pilfold](https://github.com/lpil))

- Fixed a bug where a block expression containing a singular record update would
produce invalid erlang.
([yoshi](https://github.com/joshi-monster))

- Fixed a typo in the error message when trying to import a test module into an
application module.
([John Strunk](https://github.com/jrstrunk))

- Fixed a bug where the "Extract variable" code action would erroneously extract
a pipeline step as a variable.
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- Fixed a bug where variables bound in `let assert` assignments would be allowed
to be used in the custom panic message.
([Surya Rose](https://github.com/GearsDatapacks))
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion compiler-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gleam"
version = "1.8.0"
version = "1.8.1"
authors = ["Louis Pilfold <[email protected]>"]
edition = "2021"
license-file = "LICENCE"
Expand Down
2 changes: 1 addition & 1 deletion compiler-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gleam-core"
version = "1.8.0"
version = "1.8.1"
authors = ["Louis Pilfold <[email protected]>"]
edition = "2021"
license-file = "LICENCE"
Expand Down
Loading

0 comments on commit 7707572

Please sign in to comment.