-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[Formatter]: Able to normilze symbols #13024
base: master
Are you sure you want to change the base?
Conversation
This removes all |
Thanks for the input, I will take a look into fixing that |
It should turn out to be |
It's not clear what exactly the purpose of that |
Well we need some way of taking a "raw" string and then confirming if it has a valid escape sequence or not. Although I don't know if it makes so much sense to have it as a method for a string? Or did I misunderstand what you meant there?. But surely we could have a method for strings that removes all "invalid" escape sequences. I will look into updating/adding tests for this behavior. |
Giving the formatter_spec.cr file this line: But in my normal test environment can it format Did I do something wrong or is this an error with the formatter, since I tested it without my changes and it still raises an error? |
The source in your example equals to |
Thanks ✨, I will use percent string literals, didnt think of that. |
String literals do it like this for the string contents: crystal/src/compiler/crystal/tools/formatter.cr Lines 490 to 494 in bc01989
Symbol literals shouldn't be much different. |
Yes I imagined it was something around this, I did go through and tried to search for what was causing it and then I compared the raw and value and noticed it had to be something around that. |
I tried to write it like this: Given it to the formater give: Am I doing something wrong? |
Why don't you have crystal print the string to see what it actually looks like: |
Hmmm interesting, when I debug I use Any way changing it to this: |
I know that it translate the string to: ":\c\n"" and those 2 |
@straight-shoota sorry for taking some time, been busy with exercism. I have now thought through the test files and they are now how I intend them. But that may be incorrect. |
This one line change make so the formatter can normalize symbols, it uses the
inspect
method which isn't used else where in the formatter, I am interested in hearing if that is something that should be avoided and if I should do it some other way?resolves #12938