Skip to content

Commit

Permalink
Update to Gleam 1.6.3 (#35)
Browse files Browse the repository at this point in the history
* Reset changelog for v1.7

* fix update use_manifest logic

* Changelog!

* v1.6.1

* Reintroduce exhaustiveness checking for `use` (#3880)

* fix: do not use code:del_paths since that function is not available on older versions of Erlang.

* switch to conditional compilations instead of a runtime check

* Clippy

* Clippy, again!

* Clippy, again!!

* update compiler version

* update test name

---------

Co-authored-by: Louis Pilfold <[email protected]>
Co-authored-by: Jason Sipula <[email protected]>
Co-authored-by: Gears <[email protected]>
Co-authored-by: yoshi~ <[email protected]>
  • Loading branch information
5 people authored Dec 28, 2024
1 parent 24b84c7 commit 2a140e7
Show file tree
Hide file tree
Showing 11 changed files with 546 additions and 463 deletions.
462 changes: 17 additions & 445 deletions CHANGELOG.md

Large diffs are not rendered by default.

465 changes: 465 additions & 0 deletions changelog/v1.6.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiler-cli/src/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ pub enum UseManifest {
pub fn update(packages: Vec<String>) -> Result<()> {
let paths = crate::find_project_paths()?;
let use_manifest = if packages.is_empty() {
UseManifest::Yes
} else {
UseManifest::No
} else {
UseManifest::Yes
};

// Update specific packages
Expand Down
12 changes: 10 additions & 2 deletions compiler-cli/templates/gleam@@compile.erl
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,18 @@ do_compile_elixir(Modules, Out) ->
end.

add_lib_to_erlang_path(Lib) ->
code:add_paths(filelib:wildcard([Lib, "/*/ebin"])).
code:add_paths(expand_lib_paths(Lib)).

-if(?OTP_RELEASE >= 26).
del_lib_from_erlang_path(Lib) ->
code:del_paths(filelib:wildcard([Lib, "/*/ebin"])).
code:del_paths(expand_lib_paths(Lib)).
-else.
del_lib_from_erlang_path(Lib) ->
lists:foreach(fun code:del_path/1, expand_lib_paths(Lib)).
-endif.

expand_lib_paths(Lib) ->
filelib:wildcard([Lib, "/*/ebin"]).

configure_logging() ->
Enabled = os:getenv("GLEAM_LOG") /= false,
Expand Down
2 changes: 1 addition & 1 deletion compiler-core/src/language_server/completer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ where
}

// Get all the modules that can be imported that have not already been imported.
fn completable_modules_for_import(&self) -> Vec<(&EcoString, &ModuleInterface)> {
fn completable_modules_for_import(&'a self) -> Vec<(&'a EcoString, &'a ModuleInterface)> {
let mut direct_dep_packages: std::collections::HashSet<&EcoString> =
std::collections::HashSet::from_iter(
self.compiler.project_compiler.config.dependencies.keys(),
Expand Down
4 changes: 2 additions & 2 deletions compiler-core/src/language_server/tests/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub fn show_complete(code: &str, position: Position) -> String {
fn apply_conversion(src: &str, completions: Vec<CompletionItem>, value: &str) -> String {
let completion = completions
.iter()
.find(|c| c.label == value.to_string())
.expect(&format!("no completion with value `{value}`"));
.find(|c| c.label == *value)
.unwrap_or_else(|| panic!("no completion with value `{value}`"));

let mut edits = vec![];
if let Some(lsp_types::CompletionTextEdit::Edit(edit)) = &completion.text_edit {
Expand Down
6 changes: 2 additions & 4 deletions compiler-core/src/type_/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1371,10 +1371,8 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
// Do not perform exhaustiveness checking if user explicitly used `let assert ... = ...`.
let exhaustiveness_check = self.check_let_exhaustiveness(location, value.type_(), &pattern);
match (kind, exhaustiveness_check) {
// Generated assignments should be checked before they are generated
(AssignmentKind::Generated, _) => {}
(AssignmentKind::Let, Ok(_)) => {}
(AssignmentKind::Let, Err(e)) => {
(AssignmentKind::Let | AssignmentKind::Generated, Ok(_)) => {}
(AssignmentKind::Let | AssignmentKind::Generated, Err(e)) => {
self.problems.error(e);
}
(AssignmentKind::Assert { location }, Ok(_)) => self
Expand Down
12 changes: 6 additions & 6 deletions compiler-core/src/type_/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ macro_rules! assert_warnings_with_imports {
vec![
$(("thepackage", $name, $module_src)),*
],
crate::build::Target::Erlang,
$crate::build::Target::Erlang,
None
);

Expand All @@ -272,7 +272,7 @@ macro_rules! assert_warnings_with_imports {
#[macro_export]
macro_rules! assert_warning {
($src:expr) => {
let warning = $crate::type_::tests::get_printed_warnings($src, vec![], crate::build::Target::Erlang, None);
let warning = $crate::type_::tests::get_printed_warnings($src, vec![], $crate::build::Target::Erlang, None);
assert!(!warning.is_empty());
let output = format!("----- SOURCE CODE\n{}\n\n----- WARNING\n{}", $src, warning);
insta::assert_snapshot!(insta::internals::AutoName, output, $src);
Expand Down Expand Up @@ -309,7 +309,7 @@ macro_rules! assert_js_warning {
let warning = $crate::type_::tests::get_printed_warnings(
$src,
vec![],
crate::build::Target::JavaScript,
$crate::build::Target::JavaScript,
None,
);
assert!(!warning.is_empty());
Expand All @@ -324,7 +324,7 @@ macro_rules! assert_js_no_warnings {
let warning = $crate::type_::tests::get_printed_warnings(
$src,
vec![],
crate::build::Target::JavaScript,
$crate::build::Target::JavaScript,
None,
);
assert!(warning.is_empty());
Expand All @@ -337,7 +337,7 @@ macro_rules! assert_warnings_with_gleam_version {
let warning = $crate::type_::tests::get_printed_warnings(
$src,
vec![],
crate::build::Target::Erlang,
$crate::build::Target::Erlang,
Some($gleam_version),
);
assert!(!warning.is_empty());
Expand All @@ -349,7 +349,7 @@ macro_rules! assert_warnings_with_gleam_version {
#[macro_export]
macro_rules! assert_no_warnings {
($src:expr $(,)?) => {
let warnings = $crate::type_::tests::get_warnings($src, vec![], crate::build::Target::Erlang, None);
let warnings = $crate::type_::tests::get_warnings($src, vec![], $crate::build::Target::Erlang, None);
assert_eq!(warnings, vec![]);
};
($(($package:expr, $name:expr, $module_src:literal)),+, $src:expr $(,)?) => {
Expand Down
11 changes: 11 additions & 0 deletions compiler-core/src/type_/tests/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2639,3 +2639,14 @@ pub fn main() {
"
);
}

#[test]
// https://github.com/gleam-lang/gleam/issues/3879
fn inexhaustive_use_reports_error() {
assert_error!(
r#"
use [1, 2, 3] <- todo
todo
"#
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
source: compiler-core/src/type_/tests/errors.rs
expression: "\nuse [1, 2, 3] <- todo\ntodo\n"
---
----- SOURCE CODE

use [1, 2, 3] <- todo
todo


----- ERROR
error: Inexhaustive pattern
┌─ /src/one/two.gleam:2:5
2use [1, 2, 3] <- todo
^^^^^^^^^

This assignment uses a pattern that does not match all possible values. If
one of the other values is used then the assignment will crash.

The missing patterns are:

[]
[_, _, _, _, ..]
[_, _, _]
[_, _]
[_]

Hint: Use a more general pattern or use `let assert` instead.
2 changes: 1 addition & 1 deletion compiler-core/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/// instead build from scratch
/// Note that this should be updated to correspond to the Gleam version
/// we are basing Glistix on. This is checked by packages.
pub const COMPILER_VERSION: &str = "1.6.0";
pub const COMPILER_VERSION: &str = "1.6.3";

0 comments on commit 2a140e7

Please sign in to comment.