Skip to content

8-bit \x escapes #604

@mattheww

Description

@mattheww

Problem 1

The definition of ByteEscape in §2.4.1 (fls_2ifjqwnw03ms) includes \x OctalDigit HexadecimalDigit.

ByteEscape is then used in the definition of byte literals (also in §2.4.1) and simple byte string literals (in §2.4.2.1, fls_msbaxfc09vkk).

But byte literals and simple byte string literals can also include 8-bit \x escapes (that is, escapes in which the first character after the \x is a HexadecimalDigit which isn't an OctalDigit).

So the FLS is mistakenly saying that, for example, b'\xff' isn't accepted as a byte literal and b"\xff" isn't accepted as a simple byte string literal.

Similarly the definition of SimpleCStringLiteral is based on AsciiEscape, which again includes \x OctalDigit HexadecimalDigit, but 8-bit \x escapes are allowed in simple c string literals.

Problem 2

§2.4.2.1:2 (fls_moe3zfx39ox2) reads:

A simple byte string literal is a byte string literal that consists of multiple AsciiCharacters.

while AsciiCharacter is defined in §2.1:16 (fls_PIDKEm8GiLNL) as follows:

An AsciiCharacter is any Unicode character in the range 0x00 - 0x7F, both inclusive.

But (because of the 8-bit \x escapes described above) a simple byte string literal can contain arbitrary bytes.

So I think §2.4.2.1:2 should say that a simple byte string literal is made up of bytes (compare §2.4.1:2 (fls_q0qwr83frszx) "A byte literal is a literal that denotes a fixed byte value.")

Also, where §2.4.2.1:3 (fls_vffxb6arj9jf) says

The type of a simple byte string literal of size N is &'static [u8; N].

I think it would be good to be more explicit than "size".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions