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
6 changes: 5 additions & 1 deletion compiler/noirc_frontend/src/ast/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,11 @@ impl Display for ExpressionKind {
MemberAccess(access) => access.fmt(f),
Tuple(elements) => {
let elements = vecmap(elements, ToString::to_string);
write!(f, "({})", elements.join(", "))
if elements.len() == 1 {
write!(f, "({},)", elements[0])
} else {
write!(f, "({})", elements.join(", "))
}
}
Lambda(lambda) => lambda.fmt(f),
Parenthesized(sub_expr) => write!(f, "({sub_expr})"),
Expand Down
6 changes: 5 additions & 1 deletion compiler/noirc_frontend/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,11 @@ impl std::fmt::Display for UnresolvedTypeData {
TraitAsType(s, args) => write!(f, "impl {s}{args}"),
Tuple(elements) => {
let elements = vecmap(elements, ToString::to_string);
write!(f, "({})", elements.join(", "))
if elements.len() == 1 {
write!(f, "({},)", elements[0])
} else {
write!(f, "({})", elements.join(", "))
}
}
Expression(expression) => expression.fmt(f),
Function(args, ret, env, unconstrained) => {
Expand Down
6 changes: 5 additions & 1 deletion compiler/noirc_frontend/src/ast/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,11 @@ impl Display for Pattern {
Pattern::Mutable(name, _, _) => write!(f, "mut {name}"),
Pattern::Tuple(fields, _) => {
let fields = vecmap(fields, ToString::to_string);
write!(f, "({})", fields.join(", "))
if fields.len() == 1 {
write!(f, "({},)", fields[0])
} else {
write!(f, "({})", fields.join(", "))
}
}
Pattern::Struct(typename, fields, _) => {
let fields = vecmap(fields, |(name, pattern)| format!("{name}: {pattern}"));
Expand Down
6 changes: 5 additions & 1 deletion compiler/noirc_frontend/src/hir_def/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2445,7 +2445,7 @@
}

let recur_on_binding = |id, replacement: &Type| {
// Prevent recuring forever if there's a `T := T` binding

Check warning on line 2448 in compiler/noirc_frontend/src/hir_def/types.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (recuring)
if replacement.type_variable_id() == Some(id) {
replacement.clone()
} else {
Expand Down Expand Up @@ -2531,7 +2531,7 @@
Type::Tuple(fields)
}
Type::Forall(typevars, typ) => {
// Trying to substitute_helper a variable de, substitute_bound_typevarsfined within a nested Forall

Check warning on line 2534 in compiler/noirc_frontend/src/hir_def/types.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (typevarsfined)
// is usually impossible and indicative of an error in the type checker somewhere.
for var in typevars {
assert!(!type_bindings.contains_key(&var.id()));
Expand Down Expand Up @@ -2698,7 +2698,7 @@
}
}

/// Follow bindings if this is a type variable or generic to the first non-typevariable

Check warning on line 2701 in compiler/noirc_frontend/src/hir_def/types.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (typevariable)
/// type. Unlike `follow_bindings`, this won't recursively follow any bindings on any
/// fields or arguments of this type.
pub fn follow_bindings_shallow(&self) -> Cow<Type> {
Expand All @@ -2723,7 +2723,7 @@

/// Replace any `Type::NamedGeneric` in this type with a `Type::TypeVariable`
/// using to the same inner `TypeVariable`. This is used during monomorphization
/// to bind to named generics since they are unbindable during type checking.

Check warning on line 2726 in compiler/noirc_frontend/src/hir_def/types.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (unbindable)
pub fn replace_named_generics_with_type_variables(&mut self) {
match self {
Type::FieldElement
Expand Down Expand Up @@ -3167,7 +3167,11 @@
Type::TraitAsType(_id, name, generics) => write!(f, "impl {}{:?}", name, generics),
Type::Tuple(elements) => {
let elements = vecmap(elements, |arg| format!("{:?}", arg));
write!(f, "({})", elements.join(", "))
if elements.len() == 1 {
write!(f, "({},)", elements[0])
} else {
write!(f, "({})", elements.join(", "))
}
}
Type::Bool => write!(f, "bool"),
Type::String(len) => write!(f, "str<{len:?}>"),
Expand Down Expand Up @@ -3269,7 +3273,7 @@
len.hash(state);
env.hash(state);
}
Type::Tuple(elems) => elems.hash(state),

Check warning on line 3276 in compiler/noirc_frontend/src/hir_def/types.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (elems)

Check warning on line 3276 in compiler/noirc_frontend/src/hir_def/types.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (elems)
Type::DataType(def, args) => {
def.hash(state);
args.hash(state);
Expand Down
6 changes: 5 additions & 1 deletion compiler/noirc_frontend/src/monomorphization/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,11 @@ impl std::fmt::Display for Type {
Type::Unit => write!(f, "()"),
Type::Tuple(elements) => {
let elements = vecmap(elements, ToString::to_string);
write!(f, "({})", elements.join(", "))
if elements.len() == 1 {
write!(f, "({},)", elements[0])
} else {
write!(f, "({})", elements.join(", "))
}
}
Type::Function(args, ret, env, unconstrained) => {
if *unconstrained {
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/monomorphization/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@
Zero,
^^^^ Type `Odd` is recursive
~~~~ All types in Noir must have a known size at compile-time
Succ(Odd),

Check warning on line 94 in compiler/noirc_frontend/src/monomorphization/tests.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (Succ)
}

enum Odd {
One,
Succ(Even),

Check warning on line 99 in compiler/noirc_frontend/src/monomorphization/tests.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (Succ)
}
";
let features = vec![UnstableFeature::Enums];
Expand Down Expand Up @@ -130,7 +130,7 @@
tmp$l5.1(tmp$l5.0)
}
}
fn lambda$f1(mut env$l2: (Field)) -> Field {
fn lambda$f1(mut env$l2: (Field,)) -> Field {
env$l2.0
}
");
Expand Down
Loading