crystal-lang / crystal

The Crystal Programming Language
https://crystal-lang.org
Apache License 2.0
19.39k stars 1.62k forks source link

Multiline-Symbol literals do not increase the line counter #13526

Open BlobCodes opened 1 year ago

BlobCodes commented 1 year ago

Bug Report

When using symbols which span accross multiple lines, the line counter is not increased.

For example this code:

symbol = :"M
U
L
T
I
L
I
N
E"                 
puts __LINE__

It prints 2 to the terminal, while it is actually on line 10.

nobodywasishere commented 10 months ago

Should multi-line symbols be allowed by the compiler? They would be very inconvenient to use.

BlobCodes commented 10 months ago

I think they could be useful for macros.

straight-shoota commented 10 months ago

The idea of quoted symbol identifiers is to allow almost any character as part of the symbol name. If that really needs to include LF and I don't know what kind of control characters...? 🤷 But technically it's not a big issue, there's just a minor bug in the symbol parsing logic which doesn't count the lines. So while the use case is questionable it's probably easiest to just fix this bug and allow the usage of LF in quoted symbol identifiers. There's no real harm from this.

BlobCodes commented 5 months ago

The same issue also applies to char literals.

'
'
puts __LINE__ #=> 2

LF should probably be forbidden inside char literals (it also doesn't compile with CRLF).

straight-shoota commented 5 months ago

it also doesn't compile with CRLF

That's because CRLF are two characters and a char literal contains exactly one character.