-
Notifications
You must be signed in to change notification settings - Fork 279
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
Incorrect CustomStringConvertible implementations #301
Comments
The descriptions are generated by code that is shared across all container types in this package ( |
I think it'd be a good idea to also drop the type names from Given the use of |
- For CustomStringConvertible, `description` should print elements using `String(reflecting:)` rather than `String(describing:)`, to avoid element output from interfering with syntactically relevant punctuation within structured list displays. - To make this work without making displays overly verbose, make `debugDescription` mostly the same as `description`, except for escaping raw string displays when and if needed. - Avoid printing type names in `debugDescription` — it is generally not helpful, as the type is already easily accessible elsewhere. Including it makes for overly verbose displays when the type serves as an Element of a collection. - Avoid having `debugDescription` return the empty string — it can be confusing when such a description appears in list displays. Resolves apple#301.
Resolved in #302. |
OrderedDictionary.description
does not use the same output style asDictionary
-- it prints its keys and values by callingString(describing:)
, rather than the expectedString(reflecting:)
. This allows the contents of keys and values to confusingly intermix with the syntax of the description's structural output.Information
Checklist
main
branch of this package.Steps to Reproduce
Expected behavior
I expect the code to print output that distinguishes keys from values.
Actual behavior
The sample code prints the following output:
This is extremely confusing -- the values of the keys are allowed to interfere with the syntactic punctuation in the dictionary's structured description.
In contrast, the standard
Dictionary.description
usesdebugDescription
to print its contents, preventing such confusion:The output is not exactly crystal clear, but it is at least possible to e.g. count the number of elements in the dictionary.
The text was updated successfully, but these errors were encountered: