Skip to content

Commit 1aed35d

Browse files
Fix parenthesis handling on ranges and type2
1 parent a354a5e commit 1aed35d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/parsing.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,21 +159,23 @@ fn parse_control_operator(types: &mut IntermediateTypes, parent: &Type2AndParent
159159
Type2::IntValue{ value, .. } => Some(value as i128),
160160
_ => unimplemented!("unsupported type in range control operator: {:?}", operator),
161161
};
162-
let max = match &inner_type.operator {
162+
match &inner_type.operator {
163+
// if there was only one value instead of a range, we take that value to be the max
164+
// ex: uint .size (1)
165+
None => ControlOperator::Range((None, min)),
163166
Some(op) => match op.operator {
164167
RangeCtlOp::RangeOp{ is_inclusive, ..} => {
165168
let value = match op.type2 {
166169
Type2::UintValue{ value, .. } => value as i128,
167170
Type2::IntValue{ value, ..} => value as i128,
168171
_ => unimplemented!("unsupported type in range control operator: {:?}", operator),
169172
};
170-
Some(if is_inclusive { value } else { value + 1 })
173+
let max = Some(if is_inclusive { value } else { value + 1 });
174+
ControlOperator::Range((min, max))
171175
},
172176
RangeCtlOp::CtlOp{ .. } => panic!(""),
173177
},
174-
None => min,
175-
};
176-
ControlOperator::Range((min, max))
178+
}
177179
},
178180
_ => unimplemented!("unsupported type in range control operator: {:?}", operator),
179181
};
@@ -672,6 +674,9 @@ fn rust_type_from_type2(types: &mut IntermediateTypes, type2: &Type2AndParent) -
672674
Type2::TaggedData{ tag, t, .. } => {
673675
RustType::Tagged(tag.expect("tagged data without tag not supported"), Box::new(rust_type(types, t)))
674676
},
677+
Type2::ParenthesizedType { pt, .. } => {
678+
rust_type(types, pt)
679+
},
675680
_ => {
676681
panic!("Ignoring Type2: {:?}", type2.type2);
677682
},

0 commit comments

Comments
 (0)