Skip to content

Commit

Permalink
Docs suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
jfecher committed Oct 9, 2024
1 parent d264b1d commit bfed3ea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/monomorphization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ impl<'interner> Monomorphizer<'interner> {
let actual = self.interner.id_type(arguments[0]).follow_bindings();
let expected = self.interner.id_type(expr_id).follow_bindings();

if actual.try_unify(&expected, &mut TypeBindings::new()).is_err() {
if actual.unify(&expected).is_err() {
Err(MonomorphizationError::CheckedTransmuteFailed { actual, expected, location })
} else {
// Evaluate `checked_transmute(arg)` to `{ arg }`
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/noir/standard_library/mem.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn checked_transmute<T, U>(value: T) -> U

Transmutes a value of one type into the same value but with a new type `U`.

This function is safe to use since both types are asserted to be equal later during compilation.
This function is safe to use since both types are asserted to be equal later during compilation after the concrete values for generic types become known.
This function is useful for cases where the compiler may fails a type check that is expected to pass where
a user knows the two types to be equal. For example, when using arithmetic generics there are cases the compiler
does not see as equal, such as `[Field; N*(A + B)]` and `[Field; N*A + N*B]`, which users may know to be equal.
Expand Down
6 changes: 3 additions & 3 deletions noir_stdlib/src/mem.nr
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ pub fn zeroed<T>() -> T {}

/// Transmutes a value of type T to a value of type U.
///
/// This operation is checked in that in a later stage of compilation
/// both types are asserted to be equal. If not, a compilation error is issued.
/// Both types are asserted to be equal during compilation but after type checking.
/// If not, a compilation error is issued.
///
/// This function is useful for types using arithmetic generics for cases
/// This function is useful for types using arithmetic generics in cases
/// which the compiler otherwise cannot prove equal during type checking.
/// You can use this to obtain a value of the correct type while still asserting
/// that it is equal to the previous.
Expand Down

0 comments on commit bfed3ea

Please sign in to comment.