-
Notifications
You must be signed in to change notification settings - Fork 223
Correctly handle "true" subtags in enum_keywords
macro
#6698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback. |
This does feel awkward. Why do we need this? Is that really the intention of LDML or just a letter? What is the value of this heuristic? |
@zbraniecki I think we would have awkward situations either way, because something like this: let mut v = Value::from_subtag(Some(subtag!("true")));
v.push_subtag(subtag!("bar"));
assert_eq!(v, "bar"); is also a bit awkward, so facilitating the implementation of |
So you only need this if you want to model enum_keyword!(DummyKeyword {
("false" => False),
("true" => True(DummyTrueKeyword) {
("standard" => Standard),
("rare" => Rare)
})
}, "dk"); But shouldn't that be modeled as enum_keyword!(DummyKeyword {
("false" => False),
("standard" => Standard),
("rare" => Rare),
}, "dk"); |
@robertbastian That's just an artificial test to check that Definitions like
incorrectly parse the True variant as having an explicit "true" subtag, instead of being an empty value. The test is just to ensure "true" gets mapped to the empty value, and "true-standard" doesn't get mapped to the subtag "standard", but to the subtags |
This PR modifies
unicode::Value
and theenum_keyword
macro to correctly handletrue
subtags. The added test has an extensive example of the (now fixed) incorrect behaviour.I think it's important to note that this also slightly changes the semantics of
Value
itself; previously, something likewould output the value
subtag
, while this PR makes it so that the sentinel subtagtrue
is always considered when pushing a subtag, making the above output the valuetrue-subtag
. We could also specialize onlyenum_keyword
to handle this correctly, but it seemed weird to haveenum_keyword
andValue
differ in behaviour.