Skip to content

Commit

Permalink
rebase gone wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomocavalieri committed Dec 16, 2024
1 parent 882af24 commit d280253
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 38 deletions.
13 changes: 4 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@
exist with `gleam add`.
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

<<<<<<< HEAD
- External files (such as `.mjs` and `.erl`) are now permitted in subdirectories
of `src/` and `test/`.
=======
- The compiler can now suggest to wrap a value in an `Ok` or `Error` if that can
solve a type mismatch error:

Expand Down Expand Up @@ -129,7 +125,6 @@

- FFI files (such as `.mjs` and `.erl`) are now permitted in subdirectories of
`src/` and `test/`.
>>>>>>> 6394a8477 (changelog)
([PgBiel](https://github.com/PgBiel))

- `gleam publish` now requires more verbose confirmation for publishing Gleam
Expand Down Expand Up @@ -290,10 +285,10 @@
- Fixed a bug where the inferred variant of values was not properly cached,
leading to incorrect errors on incremental builds and in the Language Server.
([Surya Rose](https://github.com/GearsDatapacks))
- Fixed a bug where Gleam would be unable to compile to BEAM bytecode if the
project path contains a non-ascii character.
([yoshi](https://github.com/joshi-monster))

- Fixed a bug where Gleam would be unable to compile to BEAM bytecode if the
project path contains a non-ascii character.
([yoshi](https://github.com/joshi-monster))

## v1.6.1 - 2024-11-19

Expand Down
30 changes: 2 additions & 28 deletions compiler-core/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(clippy::unwrap_used, clippy::expect_used)]
use crate::build::{Outcome, Runtime, Target};
use crate::diagnostic::{Diagnostic, ExtraLabel, Label, Location};
use crate::type_::collapse_links;
use crate::type_::error::{
MissingAnnotation, ModuleValueUsageContext, Named, UnknownField, UnknownTypeHint,
UnsafeRecordUpdateReason,
Expand All @@ -22,6 +23,7 @@ use std::env;
use std::fmt::{Debug, Display};
use std::io::Write;
use std::path::PathBuf;
use std::sync::Arc;
use termcolor::Buffer;
use thiserror::Error;
use vec1::Vec1;
Expand Down Expand Up @@ -1880,10 +1882,6 @@ But function expects:
text.push_str("\n\nFound type:\n\n ");
text.push_str(&printer.print_type(given));

if hint.is_some() {
text.push('\n');
}

let (main_message_location, main_message_text, extra_labels) = match situation {
// When the mismatch error comes from a case clause we want to highlight the
// entire branch (pattern included) when reporting the error; in addition,
Expand Down Expand Up @@ -3913,30 +3911,6 @@ fn hint_wrap_value_into_result(expected: &Arc<Type>, given: &Arc<Type>) -> Optio
}
}

fn hint_unwrap_result(
expected: &Arc<Type>,
given: &Arc<Type>,
printer: &mut Printer<'_>,
) -> Option<String> {
// If the got type is `Result(a, _)` and the expected one is
// `a` then we can display the hint.
let wrapped_type = given.result_ok_type()?;
if !wrapped_type.same_as(expected) {
None
} else {
Some(wrap_format!(
"If you want to get a `{}` out of a `{}` you can pattern match on it:
case result {{
Ok(value) -> todo
Error(error) -> todo
}}",
printer.print_type(expected),
printer.print_type(given),
))
}
}

fn hint_numeric_message(alt: &str, type_: &str) -> String {
format!("the {alt} operator can be used with {type_}s\n")
}
Expand Down
15 changes: 14 additions & 1 deletion compiler-core/src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,20 @@ impl Type {
(one @ Type::Named { .. }, Type::Var { type_ }) => {
type_.as_ref().borrow().same_as_other_type(one)
}
(Type::Named { .. }, Type::Named { .. }) => self == other,
(
Type::Named {
package,
module,
name,
..
},
Type::Named {
package: other_package,
module: other_module,
name: other_name,
..
},
) => package == other_package && module == other_module && name == other_name,

(Type::Fn { .. }, Type::Named { .. } | Type::Tuple { .. }) => false,
(one @ Type::Fn { .. }, Type::Var { type_ }) => {
Expand Down

0 comments on commit d280253

Please sign in to comment.