Skip to content
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 should normalize symbol literals and similar fragments #12938

Open
Tracked by #13002
HertzDevil opened this issue Jan 11, 2023 · 1 comment · May be fixed by #13024
Open
Tracked by #13002

Formatter should normalize symbol literals and similar fragments #12938

HertzDevil opened this issue Jan 11, 2023 · 1 comment · May be fixed by #13024

Comments

@HertzDevil
Copy link
Contributor

HertzDevil commented Jan 11, 2023

Currently, the formatter always leaves SymbolLiterals in the source code unchanged:

def visit(node : SymbolLiteral)
check :SYMBOL
write @token.raw
next_token
false
end

This means all of the following symbols remain after formatting, even though they are equal to each other:

:foo
:"foo"
:"fo\o" # invalid escape

Other similar fragments with redundant quotation marks that the formatter doesn't remove are:

def foo("x" y)
end

foo("x": 1)

NamedTuple("x": Int32)

{"x": 1}

Unifying these forms to the quoteless variant is desirable as it simplifies source code searching. This means:

Note that macro interpolation already applies the first two normalizations to all those fragments already.

@meatball133
Copy link
Contributor

I want to give this a shot.

@meatball133 meatball133 linked a pull request Jan 28, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants