Skip to content
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
5 changes: 4 additions & 1 deletion compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,10 @@ impl<'a> FunctionContext<'a> {
Type::Numeric(NumericType::Signed { bit_size: incoming_type_size }),
NumericType::Unsigned { bit_size: target_type_size },
) => {
if *incoming_type_size != target_type_size {
// If the target type size is 1 it means it's a cast to u1. In that case
// there's no need to cast to i1 first (which actually isn't a valid type),
// because the result will be the least significant bit anyway.
if *incoming_type_size != target_type_size && target_type_size != 1 {
value = self.insert_safe_cast(
value,
NumericType::signed(target_type_size),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "cast_signed_to_u1"
type = "bin"
authors = [""]
compiler_version = ">=0.30.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() {
let x: i32 = 1;
let _ = x as u1;
Comment thread
asterite marked this conversation as resolved.
}

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

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

Loading