Repository navigation
Paper cuts: Vec ranges as []T views, let-else return inference, usize Display, str.as_bytes (#1632 #1623 #1673 #1633 #1617 #1626) - #1702
Merged
Merged
Conversation
added 2 commits
September 25, 2026 22:58
…'s type, usize/isize print, str.as_bytes() (#1632 #1623 #1673 #1633 #1617 #1626; #1587 refused loudly) - check_slice returned 0 for a Vec base with no diagnostic, so `total(v[..])` reached MIR as a Unit operand (#1632). §4.8a: a slice is a view into any contiguous storage — a Vec range is `[]T`, a view of the Vec (D27), through a reference too. Codegen already sliced any struct base through field 0. - A range of a str is refused with the spellings that exist (`s.slice(a, b)`, `s.as_bytes()[a..b]`): a `&str` points at the string object, so a sub-range has no view type yet (#1587 stays open for that ruling). - body_return_type_info skipped a let-else's else, a binding's value, a `with` body and labeled/scoped blocks, so `fn main:` with `let Ok(x) = … else: return 1` inferred Unit and MIR's return local disagreed with the `return` (#1623). - Display for usize and isize (#1673); str.as_bytes() as the §16.5 byte view (#1633) — spelled `(*self) as []u8`: `self as []u8` on a `&str` receiver casts the reference and reads garbage (filed separately). - #1617 (static fn through an instance) and #1626 (`&Unit` cast chain) pass on main; pinned so they stay closed. Verified on a stage1 of this tree: the six new tests pass and `check src/main.w` is ok.
…s []u8` views the string, not the reference - ComptimeValue gains CV_FLOAT with an f64 payload and the literal's own text. The evaluator reads a float literal (rounded once through strtod, correctly rounded, so a folded value equals the run-time one), negates, adds/subtracts/multiplies/divides with floats or ints, compares, and interpolates it; ComptimeTransform folds it back as the literal's text or 17 significant digits, which LLVM rounds to the same double. §9.1b's `const PI = 3.14159` compiles; `const TAU = PI * 2.0` folds. - lower_cast: a reference to a str/array/slice cast to a slice reads through the reference (§3.7). It cast the pointer's bytes as the string header (str.as_bytes() spelled `self as []u8` returned garbage). Verified on a stage1 of this tree: behav_const_float.w and the extended as_bytes test pass; `check src/main.w` ok.
…length; a C cast of the str struct is not a slice (found by emit-c-smoke once the prelude's str.as_bytes() existed)
Contributor
Author
|
Seed-driven battery at 9cf4b35 (seed nightly-20260925-local-1, WITH=src/main), this host: |
ehartford
marked this pull request as ready for review
September 26, 2026 04:25
This was referenced Sep 26, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1632, #1623, #1673, #1633; pins #1617 and #1626 (already fixed on main). #1587 (str ranges) is refused loudly with the existing spellings until the str-range view representation is ruled. No ownership/drop change; batches freely. Draft until the battery is posted.