Fixed bug where temperature literals were not being calculated correctly with negative numbers

This commit is contained in:
2025-12-15 23:13:40 -07:00
parent 941e81a3e5
commit 477c2b1aef
5 changed files with 214 additions and 95 deletions

View File

@@ -15,7 +15,7 @@ use parser::{
use rust_decimal::Decimal;
use std::{borrow::Cow, collections::HashMap};
use thiserror::Error;
use tokenizer::token::Number;
use tokenizer::token::{Number, Unit};
fn extract_literal<'a>(
literal: Literal<'a>,
@@ -811,7 +811,7 @@ impl<'a> Compiler<'a> {
..
})),
..
}) => Literal::Number(Number::Integer(crc_hash_signed(&str_to_hash))),
}) => Literal::Number(Number::Integer(crc_hash_signed(&str_to_hash), Unit::None)),
LiteralOr::Or(Spanned { span, .. }) => {
return Err(Error::Unknown(
"hash only supports string literals in this context.".into(),
@@ -2022,6 +2022,7 @@ impl<'a> Compiler<'a> {
let loc = VariableLocation::Constant(Literal::Number(Number::Integer(
crc_hash_signed(&str_lit),
Unit::None,
)));
Ok(Some(CompileLocation {