Skip to content

str.as_bytes() (spec §16.5 example) does not exist; the byte view of a str is only spellable as s as []u8 #1633

Closed

Description

@ehartford

The specification's networking example (conn.write_all(response.as_bytes()).await) names as_bytes() on str; lib/std has no such method, and str methods are compiler builtins. D64's zlib/bzip2 facades take []u8, so a program compressing a string needs the byte view; the route that works is s as []u8 (Sema accepted the cast; the MIR validator refused it until the D64 PR let a str cast to a byte slice, the same {ptr, len}).

Ask: either bless s as []u8 as the spelling and fix the spec example, or add as_bytes() as a builtin over that cast. Until ruled, the D64 UAT programs write input as []u8.

Activity

  1. ehartford commented on Sep 26, 2026

    @ehartford
    ContributorAuthor

    Fixed on main by #1702 (55739d4); battery green, pinned by the behavior tests named in the PR.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions