Compare commits

..

1 Commits

2 changed files with 9 additions and 21 deletions

View File

@ -7,7 +7,6 @@ use ecow::{EcoString, eco_format};
use serde::{Serialize, Serializer}; use serde::{Serialize, Serializer};
use typst_syntax::{Span, Spanned, is_ident}; use typst_syntax::{Span, Spanned, is_ident};
use typst_utils::hash128; use typst_utils::hash128;
use unicode_segmentation::UnicodeSegmentation;
use crate::diag::{DeprecationSink, SourceResult, StrResult, bail, error}; use crate::diag::{DeprecationSink, SourceResult, StrResult, bail, error};
use crate::foundations::{ use crate::foundations::{
@ -238,11 +237,12 @@ impl Symbol {
'variants: for (i, &Spanned { ref v, span }) in variants.iter().enumerate() { 'variants: for (i, &Spanned { ref v, span }) in variants.iter().enumerate() {
modifiers.clear(); modifiers.clear();
if v.1.is_empty() || v.1.graphemes(true).nth(1).is_some() { if v.1.is_empty() {
errors.push(error!( errors.push(if v.0.is_empty() {
span, "invalid variant value: {}", v.1.repr(); error!(span, "empty default variant")
hint: "variant value must be exactly one grapheme cluster" } else {
)); error!(span, "empty variant: {}", v.0.repr())
});
} }
if !v.0.is_empty() { if !v.0.is_empty() {

View File

@ -88,26 +88,14 @@
("variant.duplicate", "y"), ("variant.duplicate", "y"),
) )
--- symbol-constructor-empty-variant-value --- --- symbol-constructor-empty-variant ---
// Error: 2:3-2:5 invalid variant value: "" // Error: 2:3-2:5 empty default variant
// Hint: 2:3-2:5 variant value must be exactly one grapheme cluster // Error: 3:3-3:16 empty variant: "empty"
// Error: 3:3-3:16 invalid variant value: ""
// Hint: 3:3-3:16 variant value must be exactly one grapheme cluster
#symbol( #symbol(
"", "",
("empty", "") ("empty", "")
) )
--- symbol-constructor-multi-cluster-variant-value ---
// Error: 2:3-2:7 invalid variant value: "aa"
// Hint: 2:3-2:7 variant value must be exactly one grapheme cluster
// Error: 3:3-3:14 invalid variant value: "bb"
// Hint: 3:3-3:14 variant value must be exactly one grapheme cluster
#symbol(
"aa",
("b", "bb")
)
--- symbol-unknown-modifier --- --- symbol-unknown-modifier ---
// Error: 13-20 unknown symbol modifier // Error: 13-20 unknown symbol modifier
#emoji.face.garbage #emoji.face.garbage