Skip to content

t27b: lower char literals natively ('a', '\n') as comptime_int #6330

Description

@gHashTag

Refs #6063

ExprLiteral(char literal) is the first blocker in the reference-backed greedy order on master 634b3ff (+5 reference-passing files).

The t27c lexer makes a char literal only from one byte or a backslash plus one byte; the parser keeps the quotes; gen-zig prints it verbatim, so Zig types it as comptime_int. t27c's optimizer never folds or propagates it (its is_literal reads integers only).

Plan: lower a char literal to an untyped integer constant in cli/t27b/src/lower.rs. Refuse by name what Zig rejects, so there is no reference result to agree with: '\0' and other escapes outside \n \r \t \\ \' \" (ExprLiteral(char escape)), a raw control byte (ExprLiteral(char byte)), and a char literal shifted by a typed or runtime amount (ExprBinary(char literal << >>); t27c prints 'a' << @intCast(k)).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions