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

meson format incorrectly converts triple quotes to single quotes when there are unescaped single quotes in the string #13564

Closed
dcbaker opened this issue Aug 19, 2024 · 1 comment · Fixed by #13574

Comments

@dcbaker
Copy link
Member

dcbaker commented Aug 19, 2024

To Reproduce
Run meson format on the following snippet:

project('triple quote format bug')
message('''Don't remove the triple quotes''')

This reproduces with both the 1.5.0 release, and with meson master (cdf646f)

Expected behavior
meson format should either 1) keep the triple quotes, or 2) escape the ' inside the string as \'

@dcbaker
Copy link
Member Author

dcbaker commented Aug 19, 2024

I may try to look at this later, but I ran into it when I was trying to write a meson.format for mesa.

dcbaker added a commit to dcbaker/meson that referenced this issue Aug 19, 2024
The following is valid meson:
```meson
a = '''This string can't be simplified'''
```
which cannot be simplified because of the `'` in it, as
```meson
a = 'This string can't be simplified'
```
Is invalid.

Potentially we could convert that with escapes, but it seems reasonable
to me to leave this, since it may be desirable to not have lots of
escapes in a string. `'''I can't believe it's her's!'''` is much more
readable than `'I can\'t believe it\'s her\'s!'`, for example.

Closes: mesonbuild#13564
dcbaker added a commit to dcbaker/meson that referenced this issue Aug 20, 2024
The following is valid meson:
```meson
a = '''This string can't be simplified'''
```
which cannot be simplified because of the `'` in it, as
```meson
a = 'This string can't be simplified'
```
Is invalid.

Potentially we could convert that with escapes, but it seems reasonable
to me to leave this, since it may be desirable to not have lots of
escapes in a string. `'''I can't believe it's her's!'''` is much more
readable than `'I can\'t believe it\'s her\'s!'`, for example.

Closes: mesonbuild#13564
eli-schwartz pushed a commit that referenced this issue Sep 16, 2024
The following is valid meson:
```meson
a = '''This string can't be simplified'''
```
which cannot be simplified because of the `'` in it, as
```meson
a = 'This string can't be simplified'
```
Is invalid.

Potentially we could convert that with escapes, but it seems reasonable
to me to leave this, since it may be desirable to not have lots of
escapes in a string. `'''I can't believe it's her's!'''` is much more
readable than `'I can\'t believe it\'s her\'s!'`, for example.

Closes: #13564
(cherry picked from commit df70680)
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.

1 participant