Skip to content

Commit

Permalink
Use parsed values in constant folding
Browse files Browse the repository at this point in the history
  • Loading branch information
GearsDatapacks committed Nov 19, 2024
1 parent cb30bd9 commit a28d7ce
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions compiler-core/src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,8 @@ fn fold_single_constant(value: &TypedConstant) -> FoldedConstant<'_> {
Constant::BinaryOperation {
left, right, name, ..
} => fold_constant_bin_op(left, right, name),
Constant::Int { value, .. } => {
FoldedConstant::Int(value.parse().expect("Syntax should be valid"))
}
Constant::Float { value, .. } => {
FoldedConstant::Float(value.parse().expect("Syntax should be valid"))
}
Constant::Int { int_value, .. } => FoldedConstant::Int(int_value.clone()),
Constant::Float { float_value, .. } => FoldedConstant::Float(float_value.clone()),
Constant::String { value, .. } => FoldedConstant::String(value.clone()),
Constant::Record { type_, name, .. } if type_.is_bool() && name == "True" => {
FoldedConstant::Bool(true)
Expand Down

0 comments on commit a28d7ce

Please sign in to comment.