Currently, Slice supports backslashes in string literals to allow things like:
[deprecated("Use \"Bar\" instead")]
struct Foo {}
So the lexer knows to treat the inner quotation marks as text.
However, after parsing, we remove these backslashes by just doing replace('\\', "") (remove all backslashes).
But this might remove backslashes the user put there intentionally.
For instance, this should reasonably be parsed down to \hello:
[deprecated("\\hello")]
Instead this will currently produce hello.
TL;DR we should change the backslash removal logic to only remove the first backslash of each pair of characters,
instead of removing all backslashes.
Note string literals are currently only allowed for attribute arguments.
Currently, Slice supports backslashes in string literals to allow things like:
So the lexer knows to treat the inner quotation marks as text.
However, after parsing, we remove these backslashes by just doing
replace('\\', "")
(remove all backslashes). But this might remove backslashes the user put there intentionally.For instance, this should reasonably be parsed down to
\hello
:Instead this will currently produce
hello
.TL;DR we should change the backslash removal logic to only remove the first backslash of each pair of characters, instead of removing all backslashes.
Note string literals are currently only allowed for attribute arguments.