Skip to content

Commit

Permalink
Update to Gleam 1.4.0 (#15)
Browse files Browse the repository at this point in the history
* Gleam v1.4.0

v1.4.0

fix-3383

Correct changelog

completions for fields

changelog

parse empty record access

finding nodes is always end inclusive

Fix generating any() for type params used once

Simplify test

Add additional test for nested types

Update tests

Add tests for custom types

The snapshots are unconfirmed

Wibble

Wibble tests

Rename tests

Revert compiler changes

Refactor Result handling

Reset tests

Handle Result type separately

Update snapshots

Add nested custom type test

Handle inferred types

Avoid panic

Clippy

Add changelog

Update itertools, strum

feat: handle improper record constructor defs with more specific error messaging and example

feat: rename to_annotation and make non-consuming

refac: use a buffer of EcoString in TypeAst.print to reduce String allocs

test: add cases to cover all variants of ExpectedRecordConstructor parser error messaging

test: rename test case for invalid constructor to show relation with other similar tests

fix: bugs in TypeAst.print, update and add tests

feat: add accessor and opaque to err msg based on whether original type was such

feat: only accept Names as fields and treat other tokens as unexpected, always expect fields for ExpectedRecordConstructor, update test names

chore: update changelog

chore: clean up outdated snaps made in this branch

Update toml_edit

Escape "module_info" in erlang target

Updated changelog

Only escape functions called "module_info"

Fix all cases for functions named "module_info" + tests

More tests!

Format

Fix changelog

Support constant string concatenation

Improve/Fix tests

Remove panics

Remove remaining foobar

Better rendering in erlang code

Better erlang bit array indentation

Changes!

Fix after rebase

Fixed formatting of comments in case branches

feat: add target flag to docs build cli

chore: changelogs

add fault tolerance for function calls

changelog

comments

Better error message for call expression in case clause guard

Function returns result with parse error

Update doc comments

Add UnexpectedToken token field

Update CHANGELOG

added fault tolerance for cases

changelog

fix edge case panic detection once cases are fault tolerant

clippy

dont allow private types to leak out of internal modules

changelog

LSP: Add extra new line after 1st import autocomplete

LSP: Use the first definition when autocompleting import

LSP: Find the 1st definition using location for autocomplete import

Changes!

Format

Initial implementation of bad name checking in the analyser

Add tests for new invalid name checking

Fix reference to discard names when diagnosing invalid upnames

Initial implementation of converting variables to snake-case

Add proper location information for possible bad names

Add lsp tests for renaming bad names

Remove `BadNames` from capnp schema

Clean up name checking functions

Move name checking from trait to separate functions

Rewrite name-checking code

Rework name-checking code

Add code action to convert `let assert Ok` into a case expression

Convert any `let assert` to a case expression

Add pattern visiting methods to AST visitor

Fix conversion from `let assert` to case when no variables are bound

Fix changelog

Only offer `let assert` conversion action in between the `let` keyword and `=`, to prevent weird behaviour with nested `let assert` statements

Fix rebase

Make function clearer with name and documentation

Add signature help

Address review comments

Add support for pipes

support argument hints in use calls

do not give hints for invalid nodes

add missing test case

review comment!

incorrect arity fault tolerance works better with labels

fix bug with func based binops

pr feedback

Fail CI if there is a merge commit

Changes!

wip

Problems class

Use Problems rather than emitter

Hook up problems to emitter again

Store warnings on module interface

Use warnings for todo detection

Cache warnings

Changes!

Punned arg parsing

Punned arg formatting

A bunch of tests

Punning parse test

CHANGELOG!

Do not auto pun arguments

Include `:` in the punned argument's span

Make test easier to read

Add missing parse failure test

Add tests for punned args hover

Remove VariableKind

Do not give different warnings for punned variables

No punning tests

Do not attach stray doc comments to next definition

Add tests for parsing

Make sure stray comments are not displayed in html doc

Make sure stray comments are formatted properly

Remove pesky println

CHANGELOG!

rebase gone wrong

Handle there being no warnings gracefully

Clean up

LSP: Support document symbols (#3275)


Add code action

pun -> label shorthand (syntax)

Always use inclusive overlap function

Various rewordings

Rename variants

Make sure changelog has consistent style

Fix bug where function hole would be turned into a shorthand label by the formatter

add completions for labels

changelog

nit

lint

include colon in label completions

pr feedback

completion snapshots include the src

render a nice cursor where the completion is

Support more bit array options for ints and floats on JavaScript










Remove bool trait impl

Update dependencies

Add field map to fn

Add action

Add regression test

Make snapshots pretty and use selector api

Clippy!

Add action tests

Rename code action

CHANGELOG!

Update deps to fix build for new Rust

Make sure shorthand label code action triggers in all cases

fix typo in language test Makefile
right-align and restyle opaque tag

Fix formatting of internal definitions

fix record constructors in guards using non-aliased names in JS

sorts completions based on where the completion came from

changelog

fix unqualified import values

rename priority and add comment

pr feedback

comments

explicit match

comments

UTF-8 constants in patterns on JavaScript


v1.4.0-rc1

Update name

Remove unused import

Fix incorrect error message on `|>` to a function with a different arity

Changes!

Report invalid name errors for type parameters

Add name checking for function type parameters, rework code action to rename invalid names

Update deps

Update deps

Remove gitpod section from CONTRIBUTING.md

Do not show completions inside comments

CHANGELOG!

Co-authored-by: Ace <therespie@gmail.com>
Co-authored-by: Ameen Radwan <ameen_radwan@intuit.com>
Co-authored-by: DeviousStoat <devious@stoat.com>
Co-authored-by: dvic <info@dvic.io>
Co-authored-by: Frank Wang <1454884738@qq.com>
Co-authored-by: GearsDatapacks <surya@seriousinfinitude.com>
Co-authored-by: Giacomo Cavalieri <giacomo.cavalieri@icloud.com>
Co-authored-by: graphiteisaac <mrminer2229.galaxycraft@gmail.com>
Co-authored-by: Juraj Petráš <jurkopetras@gmail.com>
Co-authored-by: Louis Pilfold <louis@lpil.uk>
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
Co-authored-by: Rahul Ghosal <rdghosal@gmail.com>
Co-authored-by: Richard Viney <richard.viney@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Zhomart Mukhamejanov <mzhomart@gmail.com>

* update test names

* add fix test names script

* i thought the test names were fixed

* update nix code

* fix even more test snapshots

* fix language test diff

In the original code, there is no split between erlang and JS in some code,
but changes were only being applied to erlang in our diff. Simply copied the code to both Erlang and JS

* fix flake hash

* bump flake inputs

* nix: add additional number tests from js

---------

Co-authored-by: Louis Pilfold <louis@lpil.uk>
Co-authored-by: Ace <therespie@gmail.com>
Co-authored-by: Ameen Radwan <ameen_radwan@intuit.com>
Co-authored-by: DeviousStoat <devious@stoat.com>
Co-authored-by: dvic <info@dvic.io>
Co-authored-by: Frank Wang <1454884738@qq.com>
Co-authored-by: GearsDatapacks <surya@seriousinfinitude.com>
Co-authored-by: Giacomo Cavalieri <giacomo.cavalieri@icloud.com>
Co-authored-by: graphiteisaac <mrminer2229.galaxycraft@gmail.com>
Co-authored-by: Juraj Petráš <jurkopetras@gmail.com>
Co-authored-by: Rahul Ghosal <rdghosal@gmail.com>
Co-authored-by: Richard Viney <richard.viney@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Zhomart Mukhamejanov <mzhomart@gmail.com>
  • Loading branch information
15 people authored Aug 26, 2024
1 parent 3d4600c commit 555c25c
Show file tree
Hide file tree
Showing 459 changed files with 17,742 additions and 2,352 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ jobs:

- run: cargo fmt --all -- --check

# validate-deps:
# name: validate-deps
# validate:
# name: validate
# runs-on: ubuntu-latest
# timeout-minutes: 10
# steps:
Expand Down
7 changes: 0 additions & 7 deletions .gitpod.Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions .gitpod.yml

This file was deleted.

313 changes: 312 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,328 @@
# Gleam's Changelog

## Unreleased
## v1.4.0 - 2024-08-02

### Bug Fixes

- Fixed a bug where pipe function arity errors could have an incorrect error
message.
([sobolevn](https://github.com/sobolevn))

- Fixed a bug where the case of type parameters would not be checked.
([Surya Rose](https://github.com/gearsdatapacks))

- Fixed a bug where the language server would still show completions when inside
a comment.
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

## v1.4.0-rc1 - 2024-07-29

### Build tool

- `gleam docs build` now takes an optional `--target` flag to specify the target
platform for the generated documentation.
([Jiangda Wang](https://github.com/frank-iii))

- Warnings are now emitted each time the project is built, even if the module
the warnings originated from were loaded from the cache rather than
recompiling.
([Louis Pilfold](https://github.com/lpil))

### Compiler

- Labelled arguments can now use the label shorthand syntax.
This means that when you're passing a variable as a labelled argument and it
happens to have the same name as the label, you can omit the variable name:

```gleam
pub fn date(day day: Int, month month: Month, year year: Year) -> Date {
todo
}
pub fn main() {
let day = 11
let month = October
let year = 1998
date(year:, month:, day:)
// This is the same as writing
// date(year: year, month: month, day: day)
}
```

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

- Labelled pattern variables can now use the label shorthand syntax.
This means that when you're pattern matching on a record constructor and
binding its labelled fields to variables that happen to have the same name,
you can omit the variable name:

```gleam
pub type Date
Date(day: Int, month: Month, year: Year)
}
pub fn main() {
case Date(11, October, 1998) {
Date(year:, month:, day:) -> todo
// This is the same as writing
// Date(year: year, month: month, day: day) -> todo
}
}
```

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

- The warning for the deprecated `[..]` pattern has been improved.
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- Record accessors are now fault tolerant. This means an invalid label can be
properly detected and won't invalidate the rest of the expression.
([Ameen Radwan](https://github.com/Acepie))

- Erlang type spec generation has been improved to avoid new warnings emitted in
OTP27.
([Damir Vandic](https://github.com/dvic))

- Error messages for invalid record constructors now contain a restructured
example of what the user likely intended. This is especially helpful for
users coming from other languages, like Rust or Go.

For example, provided a User type:

```gleam
pub type User {
name: String
}
```

The compiler errors with the following message:

```
error: Syntax error
┌─ /src/parse/error.gleam:3:5
3 │ name: String,
│ ^^^^ I was not expecting this
Each custom type variant must have a constructor:
pub type User {
User(
name: String,
)
}
```

([Rahul D. Ghosal](https://github.com/rdghosal))

- The `<>` string concatenation operator can now be used in constant
expressions.
([Thomas](https://github.com/DeviousStoat))

- Function calls are now fault tolerant. This means that errors in the function
call arguments won't stop the rest of the call from being analysed.
([Ameen Radwan](https://github.com/Acepie))

- The error message presented when a function is called in a guard has been
improved.
([Thomas](https://github.com/DeviousStoat))

- Case expressions are now fault tolerant. This means an subject, pattern,
guard, or then body can be properly detected and won't invalidate the rest
of the expression.
([Ameen Radwan](https://github.com/Acepie))

- Documentation comments that come before a regular comment are no longer
clumped together with the documentation of the following definition.
Now commenting out a definition won't result in its documentation merging with
the following one's.

```gleam
/// This doc comment will be ignored!
// a commented definition
// fn wibble() {}
/// Wibble's documentation.
fn wibble() { todo }
```

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

- The `little` and `big` endianness options, the `signed` and `unsigned` integer
options, and sized floats (32-bit and 64-bit), can now be used in bit array
expressions and patterns on the JavaScript target.
([Richard Viney](https://github.com/richard-viney))

- The `utf8` option can now be used with constant strings in bit array patterns
on the JavaScript target.
([Richard Viney](https://github.com/richard-viney))

### Formatter

- The formatter will no longer move a documentation comment below a regular
comment following it. This snippet of code is left as it is by the formatter:

```gleam
/// This doc comment will be ignored!
// a commented definition
// fn wibble() {}
/// Wibble's documentation.
fn wibble() {
todo
}
```

While previously all documentation comments would be merged together into one,
ignoring the regular comment separating them:

```gleam
// a commented definition
// fn wibble() {}
/// This doc comment will be ignored!
/// Wibble's documentation.
fn wibble() {
todo
}
```

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

### Language Server

- The language server can now show completions for fields if a record access is
being attempted.
([Ameen Radwan](https://github.com/Acepie))

- The language server will now insert a blank line before the first statement
when inserting a new import and there are no other imports at the top of the
module.
([Zhomart Mukhamejanov](https://github.com/Zhomart))

- The language server now suggests a code a action to rename variables, types
and functions when they don't match the Gleam naming requirements:

```gleam
let myNumber = 10
```

Becomes:

```gleam
let my_number = 10
```

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

- The language server can now suggest a code action to convert `let assert` into
a case expression:

```gleam
let assert Ok(value) = get_result()
```

Becomes:

```gleam
let value = case get_result() {
Ok(value) -> value
_ -> panic
}
```

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

- The language server can now show signature help when writing functions.
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- The language server now supports listing document symbols, such as functions
and constants, for the current Gleam file.
([PgBiel](https://github.com/PgBiel))

- The language server can now suggest a code action to automatically use
shorthand labels where possible:

```gleam
case date {
Day(day: day, month: month, year: year) -> todo
}
```

Becomes:

```gleam
case date {
Day(day:, month:, year:) -> todo
}
```

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

- The language server can now show completions for labels when writing a
function call or record construction.
([Ameen Radwan](https://github.com/Acepie))

- The language server can now suggest a code action to fill in the labels of a
function call:

```gleam
pub type Date {
Date(year: Int, month: Int, day: Int)
}
pub fn main() {
Date()
}
```

Becomes:

```gleam
pub type Date {
Date(year: Int, month: Int, day: Int)
}
pub fn main() {
Date(year: todo, month: todo, day: todo)
}
```

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

- Completions are now sorted by priority based on why the completion is in the
list. This means that more specific completions like labels and local
definitions will be shown before more broad completions like functions from a
not yet imported module.
([Ameen Radwan](https://github.com/Acepie))

### Bug Fixes

- Functions, types and constructors named `module_info` are now escaped
in generated Erlang code to avoid conflicts with the builtin
`module_info/0` and `module_info/1` functions.
([Juraj Petráš](https://github.com/Hackder))

- Fixed formatting of comments at the start of a case branch.
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- Fixed a bug where a private type could be leaked from an internal module.
([Ameen Radwan](https://github.com/Acepie))

- Fixed a bug where certain binops would not wrap their arguments properly
thus generating invalid JavaScript.
([Ameen Radwan](https://github.com/Acepie))

- Fixed formatting of function definitions marked as `@internal`
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- Fixed a bug where importing a record constructor in an unqualified fashion and
aliasing it and then using it in a case guard expression would generate
invalid JavaScript.
([PgBiel](https://github.com/PgBiel))

## v1.3.2 - 2024-07-11

### Language Server
Expand Down
6 changes: 0 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ Code changes to Gleam are welcomed via the process below.
4. Once the changes have been approved the code will be rebased into the
`main` branch.

## Hacking on Gleam in Gitpod

If you have a web browser, you can get a fully pre-configured Gleam development environment in one click:

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/gleam-lang/gleam)

## Local development

To run the compiler tests. This will require a recent stable version of Rust
Expand Down
Loading

0 comments on commit 555c25c

Please sign in to comment.