Skip to content

core: add fixed String<N> primitives#1437

Open
g-r-a-n-t wants to merge 1 commit into
argotorg:masterfrom
g-r-a-n-t:string-erg
Open

core: add fixed String<N> primitives#1437
g-r-a-n-t wants to merge 1 commit into
argotorg:masterfrom
g-r-a-n-t:string-erg

Conversation

@g-r-a-n-t
Copy link
Copy Markdown
Collaborator

@g-r-a-n-t g-r-a-n-t commented May 8, 2026

Added core String<N> utilities for fixed-width byte round-trips, effective byte length, concatenation, and equality in const and runtime code.

closes #1435

@g-r-a-n-t g-r-a-n-t marked this pull request as draft May 8, 2026 02:39
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1f1cee5800

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/hir/src/analysis/semantic/ctfe/machine.rs Outdated
@g-r-a-n-t g-r-a-n-t force-pushed the string-erg branch 6 times, most recently from fefec1d to 844b6c5 Compare May 13, 2026 02:29
@g-r-a-n-t g-r-a-n-t marked this pull request as ready for review May 13, 2026 03:34
@g-r-a-n-t g-r-a-n-t changed the title core: add fixed String<N> primitives core: add fixed String<N> primitives May 13, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 844b6c5e54

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/mir/src/runtime/lower/type_info.rs
g-r-a-n-t added a commit to g-r-a-n-t/fe that referenced this pull request May 13, 2026
Add core String<N> utilities for fixed-width byte round-trips, effective length, concatenation, and equality.

Keep CTFE and runtime casts consistent for fixed strings, add runtime/CTFE coverage, and include the release note for PR argotorg#1437.
g-r-a-n-t added a commit to g-r-a-n-t/fe that referenced this pull request May 13, 2026
Add core String<N> utilities for fixed-width byte round-trips, effective length, concatenation, and equality.

Keep CTFE and runtime casts consistent for fixed strings, add runtime/CTFE coverage, and include the release note for PR argotorg#1437.
g-r-a-n-t added a commit to g-r-a-n-t/fe that referenced this pull request May 13, 2026
Add core String<N> utilities for fixed-width byte round-trips, effective length, concatenation, and equality.

Keep CTFE and runtime casts consistent for fixed strings, add runtime/CTFE coverage, and include the release note for PR argotorg#1437.
@g-r-a-n-t g-r-a-n-t requested a review from cburgdorf May 13, 2026 21:40
Add core String<N> utilities for fixed-width byte round-trips, effective length, concatenation, and equality.

Keep CTFE and runtime casts consistent for fixed strings, add runtime/CTFE coverage, and include the release note for PR argotorg#1437.
Copy link
Copy Markdown
Collaborator

@cburgdorf cburgdorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a significant finding:

/tmp/fe-pr-1437.ntvyMt/ingots/core/src/string.fe:12: String::as_bytes() exposes intrinsic::__as_bytes as a runtime-usable public method, but that intrinsic currently appears to have CTFE support only. A
real runtime path with a String parameter fails codegen with invalid runtime package: InvalidReturnClass. Since len() and concat() both call as_bytes(), this breaks the advertised runtime utilities for
non-constant values. Minimal repro I used:

    fn fifth_byte(s: String<8>) -> u8 {
        let bytes: [u8; 8] = s.as_bytes()
        bytes[4]
    }

Running fe test on that helper failed in Sonatina emission before tests ran. The existing fixture passes because it only exercises literals/local constants, not a true runtime String input. This needs
runtime lowering for __as_bytes or an implementation based on runtime-supported word operations, plus a fixture with a String parameter/storage value.

@@ -6,7 +6,8 @@ use salsa::Update;
use super::{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth to ask the agent to separate these changes into its own commit just to keep the history a bit cleaner.

@sbillig
Copy link
Copy Markdown
Collaborator

sbillig commented May 15, 2026

String::as_bytes() exposes intrinsic::__as_bytes as a runtime-usable public method, but that intrinsic currently appears to have CTFE support only.

Yeah, that intrinsic was added to make const fn sol work, and it's currently CTFE-only. We should definitely have the ability to convert types to bytes at runtime; I'm not sure what the best way to do this is.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make String<N> ergonomic for compile-time + runtime composition (concat + length + bytes round-trip)

3 participants