Skip to content

Commit 9122022

Browse files
committed
Format
1 parent 6e36cb6 commit 9122022

File tree

5 files changed

+27
-16
lines changed

5 files changed

+27
-16
lines changed

quiver-compiler/src/compiler/pattern.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,9 @@ fn check_match_tuple_match(
459459
.lookup_type(&type_id)
460460
.ok_or(Error::TypeNotInRegistry { type_id })?;
461461

462-
if tuple.name.as_ref() != tuple_info.name.as_ref() || tuple.fields.len() != tuple_info.fields.len() {
462+
if tuple.name.as_ref() != tuple_info.name.as_ref()
463+
|| tuple.fields.len() != tuple_info.fields.len()
464+
{
463465
return Ok(None);
464466
}
465467

quiver-compiler/src/compiler/typing.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ impl TypeContext {
105105
}
106106

107107
// Register the tuple type with the is_partial flag
108-
let type_id = program.register_type_with_partial(tuple.name, fields, tuple.is_partial);
108+
let type_id =
109+
program.register_type_with_partial(tuple.name, fields, tuple.is_partial);
109110

110111
// Return Type::Partial for partial types, Type::Tuple for concrete types
111112
if tuple.is_partial {

quiver-compiler/src/parser.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ fn partial_type(input: &str) -> IResult<&str, Type> {
301301
),
302302
|tuple_type: &TupleType| {
303303
// Empty partial types are allowed, or at least one field must be named
304-
tuple_type.fields.is_empty() || tuple_type.fields.iter().any(|f| f.name.is_some())
304+
tuple_type.fields.is_empty()
305+
|| tuple_type.fields.iter().any(|f| f.name.is_some())
305306
},
306307
),
307308
)),
@@ -420,7 +421,7 @@ fn function_type(input: &str) -> IResult<&str, Type> {
420421

421422
fn function_input_type(input: &str) -> IResult<&str, Type> {
422423
alt((
423-
partial_type, // Must come before grouping parentheses
424+
partial_type, // Must come before grouping parentheses
424425
delimited(pair(char('('), ws0), type_definition, pair(ws0, char(')'))),
425426
tuple_type,
426427
primitive_type,
@@ -431,7 +432,7 @@ fn function_input_type(input: &str) -> IResult<&str, Type> {
431432

432433
fn function_output_type(input: &str) -> IResult<&str, Type> {
433434
alt((
434-
partial_type, // Must come before grouping parentheses
435+
partial_type, // Must come before grouping parentheses
435436
delimited(pair(char('('), ws0), type_definition, pair(ws0, char(')'))),
436437
tuple_type,
437438
primitive_type,
@@ -443,7 +444,7 @@ fn function_output_type(input: &str) -> IResult<&str, Type> {
443444
fn base_type(input: &str) -> IResult<&str, Type> {
444445
alt((
445446
tuple_type,
446-
partial_type, // Must come before grouping parentheses to have priority
447+
partial_type, // Must come before grouping parentheses to have priority
447448
primitive_type,
448449
type_cycle,
449450
process_type,
@@ -533,13 +534,10 @@ fn tuple_field(input: &str) -> IResult<&str, TupleField> {
533534
},
534535
),
535536
// Spread with identifier: ...identifier
536-
map(
537-
preceded(tag("..."), identifier),
538-
|id| TupleField {
539-
name: None,
540-
value: FieldValue::Spread(Some(id)),
541-
},
542-
),
537+
map(preceded(tag("..."), identifier), |id| TupleField {
538+
name: None,
539+
value: FieldValue::Spread(Some(id)),
540+
}),
543541
// Spread chained value: ...
544542
map(tag("..."), |_| TupleField {
545543
name: None,

quiver-core/src/executor.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,10 @@ impl Executor {
610610
// Use Type::is_compatible for structural checking
611611
let actual_type = Type::Tuple(*actual_type_id);
612612
// Check if type_id refers to a partial type
613-
let expected_type = if self.lookup_type(&type_id).is_some_and(|info| info.is_partial) {
613+
let expected_type = if self
614+
.lookup_type(&type_id)
615+
.is_some_and(|info| info.is_partial)
616+
{
614617
Type::Partial(type_id)
615618
} else {
616619
Type::Tuple(type_id)

quiver-core/src/format.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ pub fn format_type(program: &crate::program::Program, type_def: &Type) -> String
5454
Type::Tuple(type_id) | Type::Partial(type_id) => {
5555
let is_partial = matches!(type_def, Type::Partial(_));
5656
if let Some(type_info) = program.lookup_type(type_id) {
57-
let field_strs: Vec<String> = type_info.fields
57+
let field_strs: Vec<String> = type_info
58+
.fields
5859
.iter()
5960
.map(|(field_name, field_type)| {
6061
if let Some(field_name) = field_name {
@@ -71,7 +72,13 @@ pub fn format_type(program: &crate::program::Program, type_def: &Type) -> String
7172
if field_strs.is_empty() {
7273
type_name.to_string()
7374
} else {
74-
format!("{}{}{}{}", type_name, bracket.0, field_strs.join(", "), bracket.1)
75+
format!(
76+
"{}{}{}{}",
77+
type_name,
78+
bracket.0,
79+
field_strs.join(", "),
80+
bracket.1
81+
)
7582
}
7683
} else {
7784
format!("{}{}{}", bracket.0, field_strs.join(", "), bracket.1)

0 commit comments

Comments
 (0)