summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLingkang <karlzhu12@gmail.com>2024-08-16 03:53:59 +0800
committerGitHub <noreply@github.com>2024-08-15 19:53:59 +0000
commit0edd8ec93d16a397e58cebaa215b6c14cd24de8f (patch)
treeb8152006cb1d46d2772868e365168d1529a32618 /crates
parentccd45241061be149687aec04db43dec96d8a961d (diff)
Improve `repr` for `type(none)` and `type(auto)` (#4730)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates')
-rw-r--r--crates/typst/src/foundations/ty.rs13
-rw-r--r--crates/typst/src/foundations/value.rs3
2 files changed, 14 insertions, 2 deletions
diff --git a/crates/typst/src/foundations/ty.rs b/crates/typst/src/foundations/ty.rs
index b34393b3..3bcde61f 100644
--- a/crates/typst/src/foundations/ty.rs
+++ b/crates/typst/src/foundations/ty.rs
@@ -5,7 +5,9 @@ use ecow::{eco_format, EcoString};
use once_cell::sync::Lazy;
use crate::diag::StrResult;
-use crate::foundations::{cast, func, Func, NativeFuncData, Repr, Scope, Value};
+use crate::foundations::{
+ cast, func, AutoValue, Func, NativeFuncData, NoneValue, Repr, Scope, Value,
+};
use crate::utils::Static;
#[rustfmt::skip]
@@ -148,7 +150,14 @@ impl Debug for Type {
impl Repr for Type {
fn repr(&self) -> EcoString {
- self.long_name().into()
+ if *self == Type::of::<AutoValue>() {
+ "type(auto)"
+ } else if *self == Type::of::<NoneValue>() {
+ "type(none)"
+ } else {
+ self.long_name()
+ }
+ .into()
}
}
diff --git a/crates/typst/src/foundations/value.rs b/crates/typst/src/foundations/value.rs
index 05abbfba..78769900 100644
--- a/crates/typst/src/foundations/value.rs
+++ b/crates/typst/src/foundations/value.rs
@@ -727,6 +727,9 @@ mod tests {
fn test_value_debug() {
// Primitives.
test(Value::None, "none");
+ test(Value::Auto, "auto");
+ test(Value::None.ty(), "type(none)");
+ test(Value::Auto.ty(), "type(auto)");
test(false, "false");
test(12i64, "12");
test(3.24, "3.24");