From c3408a56c12661f36b37a2f79009468fe1ae589c Mon Sep 17 00:00:00 2001 From: Scott Richmond Date: Wed, 4 Dec 2024 19:13:25 -0500 Subject: [PATCH] ensure inlined and allocated strings are equal --- src/main.rs | 8 ++------ src/value.rs | 3 +++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index ec22849..e482046 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,12 +58,8 @@ use crate::base::*; pub fn main() { let src = " -let foo = :foo -let bar = 42 -let baz = \"foo bar baz\" -let quux = (1, 2, [3, 4, #{:five 6, :seven 8}]) -\"{foo} {bar} {baz} -{quux} {fuzz} TADA!\" +let foo = \"foo\" +eq (\"foo\", \"{foo}\") "; let (tokens, lex_errs) = lexer().parse(src).into_output_errors(); if !lex_errs.is_empty() { diff --git a/src/value.rs b/src/value.rs index 87f08d5..f434639 100644 --- a/src/value.rs +++ b/src/value.rs @@ -160,6 +160,9 @@ impl<'src> PartialEq for Value<'src> { (Value::Boolean(x), Value::Boolean(y)) => x == y, (Value::Number(x), Value::Number(y)) => x == y, (Value::InternedString(x), Value::InternedString(y)) => x == y, + (Value::AllocatedString(x), Value::AllocatedString(y)) => x == y, + (Value::InternedString(x), Value::AllocatedString(y)) => *x == **y, + (Value::AllocatedString(x), Value::InternedString(y)) => **x == *y, (Value::Keyword(x), Value::Keyword(y)) => x == y, (Value::Tuple(x), Value::Tuple(y)) => x == y, (Value::List(x), Value::List(y)) => x == y,