Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Gleam 1.3.1 #11

Merged
merged 8 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@
### Language Server

### Bug Fixes

## v1.3.1 - 2024-07-10

### Bug Fixes

- Fixes a bug with import cycle detection when there is more than 2 imports in the cycle
([Ameen Radwan](https://github.com/Acepie))
12 changes: 6 additions & 6 deletions Cargo.lock

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

10 changes: 6 additions & 4 deletions compiler-core/src/build/package_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,17 @@ where
.enumerate()
.map(|(i, module)| {
// cycles are in order of reference so get next in list or loop back to first
let ind = if i == modules.len() - 1 { 0 } else { i + 1 };
let next = modules.get(ind).expect("next module must exist");
let index_of_imported = if i == 0 { modules.len() - 1 } else { i - 1 };
let imported_module = modules
.get(index_of_imported)
.expect("importing module must exist");
let input = dep_location_map.get(module).expect("dependency must exist");
let location = match input {
Input::New(module) => {
let (_, location) = module
.dependencies
.iter()
.find(|d| &d.0 == next)
.find(|d| &d.0 == imported_module)
.expect("import must exist for there to be a cycle");
ImportCycleLocationDetails {
location: *location,
Expand All @@ -306,7 +308,7 @@ where
let (_, location) = cached_module
.dependencies
.iter()
.find(|d| &d.0 == next)
.find(|d| &d.0 == imported_module)
.expect("import must exist for there to be a cycle");
let src = self
.io
Expand Down
2 changes: 1 addition & 1 deletion nix/glistix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ rustPlatform.buildRustPackage {
buildInputs = [ openssl ] ++
lib.optionals stdenv.isDarwin [ Security SystemConfiguration ];

cargoHash = "sha256-I5oYfY4zcuhDe5WsbWzso+CFafqymOYEmxD4DmV/NOo=";
cargoHash = "sha256-rifIMUYfnmVCaS+OaQ3POEaZj00cU3Biaz2ZKj2eFL4=";

meta = with lib; {
description = "A fork of the Gleam compiler with a Nix backend";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import one
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import one
import three
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ source: test-package-compiler/src/generated_tests.rs
expression: "./cases/import_cycle_multi"
---
error: Import cycle
┌─ src/two.gleam:1:1
┌─ src/three.gleam:1:1
1 │ import one
│ ^ Imported here
┌─ src/two.gleam:1:1
1 │ import three
│ ^ Imported here
┌─ src/one.gleam:1:1
Expand All @@ -16,6 +21,8 @@ error: Import cycle
The import statements for these modules form a cycle:

┌─────┐
│ three
│ ↓
│ two
│ ↓
│ one
Expand Down
Loading