Section 7A: Core Built-ins
Goal: Type conversions, assertions, I/O, and core built-in functions
SPEC:
spec/annex-c-built-in-functions.mdPROPOSALS:
proposals/approved/as-conversion-proposal.md— Type conversion syntaxproposals/approved/developer-functions-proposal.md— Developer convenience functionsproposals/approved/embed-expression-proposal.md— Compile-time file embeddingproposals/approved/char-byte-classification-proposal.md— Char/byte classification methodsproposals/approved/byte-string-access-proposal.md— Byte-level string access
7A.1 Type Conversions
PROPOSAL:
proposals/approved/as-conversion-proposal.mdType conversions use
as/as?syntax instead ofint(),float(), etc. This removes the special-case exception for positional arguments.
-
Implement:
As<T>trait — infallible conversions- Rust Tests:
ori_types/src/check/traits/as_trait.rs— As trait tests - Ori Tests:
tests/spec/stdlib/conversions.ori - LLVM Support: LLVM codegen for As trait
- LLVM Rust Tests:
ori_llvm/tests/conversion_tests.rs— As trait codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement:
TryAs<T>trait — fallible conversions returningOption<T>- Rust Tests:
ori_types/src/check/traits/try_as_trait.rs— TryAs trait tests - Ori Tests:
tests/spec/stdlib/conversions.ori - LLVM Support: LLVM codegen for TryAs trait
- LLVM Rust Tests:
ori_llvm/tests/conversion_tests.rs— TryAs trait codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement:
x as Tsyntax — desugars toAs<T>.as(self: x)- Rust Tests:
ori_eval/src/interpreter/as_conversion.rs— as syntax tests - Ori Tests:
tests/spec/expressions/as_conversion.ori - LLVM Support: LLVM codegen for as syntax
- LLVM Rust Tests:
ori_llvm/tests/conversion_tests.rs— as syntax codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement:
x as? Tsyntax — desugars toTryAs<T>.try_as(self: x)- Rust Tests:
ori_eval/src/interpreter/as_conversion.rs— as? syntax tests - Ori Tests:
tests/spec/expressions/as_conversion.ori - LLVM Support: LLVM codegen for as? syntax
- LLVM Rust Tests:
ori_llvm/tests/conversion_tests.rs— as? syntax codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Standard
Asimplementationsimpl int: As<float>— widening (infallible)impl int: As<str>— formatting (infallible)impl float: As<str>— formatting (infallible)impl bool: As<str>— “true”/“false” (infallible)impl char: As<int>— codepoint (infallible)- Ori Tests:
tests/spec/stdlib/as_impls.ori - LLVM Support: LLVM codegen for standard As implementations
- LLVM Rust Tests:
ori_llvm/tests/conversion_tests.rs— As implementations codegen - AOT Tests: No AOT coverage yet
-
Implement: Standard
TryAsimplementationsimpl str: TryAs<int>— parsing (fallible)impl str: TryAs<float>— parsing (fallible)impl int: TryAs<byte>— range check (fallible)impl int: TryAs<char>— valid codepoint check (fallible)- Ori Tests:
tests/spec/stdlib/try_as_impls.ori - LLVM Support: LLVM codegen for standard TryAs implementations
- LLVM Rust Tests:
ori_llvm/tests/conversion_tests.rs— TryAs implementations codegen - AOT Tests: No AOT coverage yet
-
Implement: Compile-time enforcement —
asonly for infallible conversions- Rust Tests:
ori_types/src/check/as_conversion.rs— enforcement tests - Ori Tests:
tests/compile-fail/as_fallible.ori - LLVM Support: LLVM codegen for as conversion enforcement
- LLVM Rust Tests:
ori_llvm/tests/conversion_tests.rs— as enforcement codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Float truncation methods (not
as)float.truncate() -> int— toward zerofloat.round() -> int— nearestfloat.floor() -> int— toward negative infinityfloat.ceil() -> int— toward positive infinity- Ori Tests:
tests/spec/stdlib/float_methods.ori - LLVM Support: LLVM codegen for float truncation methods
- LLVM Rust Tests:
ori_llvm/tests/conversion_tests.rs— float truncation codegen - AOT Tests: No AOT coverage yet
-
Remove:
int(),float(),str(),byte()function syntax- These are replaced by
as/as?syntax - No migration period needed if implementing fresh
- LLVM Support: LLVM codegen removal of legacy conversion functions
- LLVM Rust Tests:
ori_llvm/tests/conversion_tests.rs— verify legacy functions removed - AOT Tests: No AOT coverage yet
- These are replaced by
7A.2 Assertions
-
Implement:
assert(cond:)[done] (2026-02-10)- Ori Tests: Used in hundreds of tests across test suite (
assert(cond: ...)) - LLVM Support: LLVM codegen for assert
- LLVM Rust Tests:
ori_llvm/tests/assertion_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Ori Tests: Used in hundreds of tests across test suite (
-
Implement:
assert_eq(actual:, expected:)[done] (2026-02-10)- Ori Tests: Used in hundreds of tests across test suite
- LLVM Support: LLVM codegen for assert_eq
- LLVM Rust Tests:
ori_llvm/tests/assertion_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
-
Implement:
assert_ne(actual:, expected:)[done] (2026-02-10)- Ori Tests: Used in module tests (
tests/spec/modules/) - LLVM Support: LLVM codegen for assert_ne
- LLVM Rust Tests:
ori_llvm/tests/assertion_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Ori Tests: Used in module tests (
-
Implement:
assert_some(x)— spec/annex-c-built-in-functions.md § assert_some- Ori Tests: Not verified — not found in test suite
- LLVM Support: LLVM codegen for assert_some
-
Implement:
assert_none(x)— spec/annex-c-built-in-functions.md § assert_none- Ori Tests: Not verified — not found in test suite
- LLVM Support: LLVM codegen for assert_none
-
Implement:
assert_ok(x)— spec/annex-c-built-in-functions.md § assert_ok- Ori Tests: Not verified — not found in test suite
- LLVM Support: LLVM codegen for assert_ok
-
Implement:
assert_err(x)— spec/annex-c-built-in-functions.md § assert_err- Ori Tests: Not verified — not found in test suite
- LLVM Support: LLVM codegen for assert_err
7A.3 I/O and Other
-
Implement:
print(x)[done] (2026-02-10)- Ori Tests: Used in test suite; LLVM has
_ori_printruntime function - LLVM Support: LLVM codegen for print —
_ori_printin runtime - LLVM Rust Tests:
ori_llvm/tests/io_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Ori Tests: Used in test suite; LLVM has
-
Implement:
compare(a, b)[done] (2026-02-10)- Ori Tests:
tests/spec/traits/core/comparable.ori— 58 tests for.compare(other:) - LLVM Support: LLVM codegen for compare — inline IR in lower_calls.rs
- LLVM Rust Tests:
ori_llvm/tests/comparison_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Ori Tests:
-
Implement:
min(a, b),max(a, b)[done] (2026-02-10)- Ori Tests: Prelude functions available, verified in Section 4.6
- LLVM Support: LLVM codegen for min/max
- LLVM Rust Tests:
ori_llvm/tests/comparison_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
-
Implement:
panic(msg)[done] (2026-02-10)- Ori Tests: Used in
#failtest attributes (division by zero, index out of bounds) - LLVM Support: LLVM codegen for panic —
_ori_panicin runtime - LLVM Rust Tests:
ori_llvm/tests/panic_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Ori Tests: Used in
7A.4 Float NaN Behavior
Decision: NaN comparisons panic (no proposal needed — behavioral decision)
Fits Ori’s “bugs should be caught” philosophy (same as integer overflow).
-
Implement: NaN comparison panics
NaN == NaN→ PANICNaN < x→ PANICNaN > x→ PANIC- Rust Tests:
ori_eval/src/interpreter/binary.rs— NaN comparison tests - Ori Tests:
tests/spec/types/float_nan.ori - LLVM Support: LLVM codegen for NaN comparison panic
- LLVM Rust Tests:
ori_llvm/tests/float_tests.rs— NaN comparison panic codegen - AOT Tests: No AOT coverage yet
-
Implement: NaN-producing operations don’t panic (only comparisons)
0.0 / 0.0→ NaN (allowed)- Using NaN in arithmetic → NaN (allowed)
- Comparing NaN → PANIC
- Ori Tests:
tests/spec/types/float_nan_ops.ori - LLVM Support: LLVM codegen for NaN-producing operations
- LLVM Rust Tests:
ori_llvm/tests/float_tests.rs— NaN operations codegen - AOT Tests: No AOT coverage yet
7A.5 Developer Functions
PROPOSAL:
proposals/approved/developer-functions-proposal.md
todo,unreachable, anddbgfor developer convenience. These provide semantic meaning (unfinished vs. impossible code) and inline debugging.
-
Implement:
todo()andtodo(reason:)— Mark unfinished code- Returns
Never, panics with “not yet implemented at file:line” - Location information captured at compile time
- Rust Tests:
ori_eval/src/function_val.rs— todo tests - Ori Tests:
tests/spec/stdlib/developer_functions.ori - LLVM Support: LLVM codegen for todo
- LLVM Rust Tests:
ori_llvm/tests/developer_tests.rs— todo codegen - AOT Tests: No AOT coverage yet
- Returns
-
Implement:
unreachable()andunreachable(reason:)— Mark impossible code- Returns
Never, panics with “unreachable code reached at file:line” - Semantically distinct from
todo(impossible vs. not done) - Rust Tests:
ori_eval/src/function_val.rs— unreachable tests - Ori Tests:
tests/spec/stdlib/developer_functions.ori - LLVM Support: LLVM codegen for unreachable
- LLVM Rust Tests:
ori_llvm/tests/developer_tests.rs— unreachable codegen - AOT Tests: No AOT coverage yet
- Returns
-
Implement:
dbg(value:)anddbg(value:, label:)— Debug printing- Generic:
dbg<T: Debug>(value: T) -> T - Writes to stderr via Print capability
- Output format:
[file:line] = valueor[file:line] label = value - Returns value unchanged for inline use
- Rust Tests:
ori_eval/src/function_val.rs— dbg tests - Ori Tests:
tests/spec/stdlib/developer_functions.ori - LLVM Support: LLVM codegen for dbg
- LLVM Rust Tests:
ori_llvm/tests/developer_tests.rs— dbg codegen - AOT Tests: No AOT coverage yet
- Generic:
-
Implement: Compile-time location capture for all three functions
- Location passed implicitly by compiler, not visible in user signature
- Rust Tests:
ori_types/src/infer/expr/identifiers.rs— location capture tests - Ori Tests: Verify location appears in panic messages/dbg output
7A.6 Additional Built-in Functions
Proposal: proposals/approved/additional-builtins-proposal.md
Formalizes repeat, compile_error, PanicInfo, and clarifies ?? operator semantics.
repeat Function
-
Implement:
repeat<T: Clone>(value: T) -> impl Iterator— infinite iterator of cloned values- Rust Tests:
ori_eval/src/function_val.rs— repeat tests - Ori Tests:
tests/spec/stdlib/repeat.ori - LLVM Support: LLVM codegen for repeat
- LLVM Rust Tests:
ori_llvm/tests/iterator_tests.rs— repeat codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Clone requirement enforcement — T must implement Clone
- Rust Tests:
ori_types/src/infer/expr/identifiers.rs— repeat type checking - Ori Tests:
tests/compile-fail/repeat_not_clone.ori
- Rust Tests:
-
Implement: Integration with Iterator trait — .take(), .collect(), etc.
- Ori Tests:
tests/spec/stdlib/repeat_iterator.ori
- Ori Tests:
PanicInfo Type
Proposal: proposals/approved/panic-handler-proposal.md (extends basic definition)
Spec: spec/17-errors-and-panics.md § PanicInfo Type (updated with full structure)
-
Spec: PanicInfo type definition —
{ message, location, stack_trace, thread_id }DONE -
Implement:
PanicInfostruct type —{ message: str, location: TraceEntry, stack_trace: [TraceEntry], thread_id: Option<int> }- Rust Tests:
ori_types/src/check/registration/mod.rs— PanicInfo type tests - Ori Tests:
tests/spec/types/panic_info.ori - LLVM Support: LLVM codegen for PanicInfo
- LLVM Rust Tests:
ori_llvm/tests/type_tests.rs— PanicInfo codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement:
Printableimpl for PanicInfo- Ori Tests:
tests/spec/types/panic_info_printable.ori
- Ori Tests:
-
Implement:
Debugimpl for PanicInfo- Ori Tests:
tests/spec/types/panic_info_debug.ori
- Ori Tests:
-
Add to prelude: PanicInfo available without import
- Ori Tests:
tests/spec/prelude/panic_info.ori
- Ori Tests:
@panic Handler
Proposal: proposals/approved/panic-handler-proposal.md
App-wide panic handler function that executes before program termination.
-
Implement: Recognize
@panicas special function (like@main)- Rust Tests:
ori_types/src/check/special_functions.rs— @panic recognition - Ori Tests:
tests/spec/declarations/panic_handler.ori - LLVM Support: LLVM codegen for @panic function recognition
- LLVM Rust Tests:
ori_llvm/tests/panic_tests.rs— @panic recognition codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Validate signature
(PanicInfo) -> void- Rust Tests:
ori_types/src/check/special_fns.rs— @panic signature validation - Ori Tests:
tests/compile-fail/panic_handler_wrong_sig.ori
- Rust Tests:
-
Implement: Error if multiple
@panicdefinitions- Rust Tests:
ori_types/src/check/special_functions.rs— multiple @panic error - Ori Tests:
tests/compile-fail/multiple_panic_handlers.ori
- Rust Tests:
-
Implement: Implicit stderr for print() inside @panic
- Rust Tests:
ori_eval/src/interpreter/panic_handler.rs— stderr redirection - Ori Tests:
tests/spec/declarations/panic_print_stderr.ori - LLVM Support: LLVM codegen for stderr redirection in @panic
- LLVM Rust Tests:
ori_llvm/tests/panic_tests.rs— stderr redirection codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Runtime panic hook installation at program start
- Rust Tests:
ori_eval/src/interpreter/panic.rs— hook installation - LLVM Support: LLVM codegen for panic hook installation
- LLVM Rust Tests:
ori_llvm/tests/panic_tests.rs— hook installation codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Construct PanicInfo (message, location, stack_trace, thread_id) on panic
- Rust Tests:
ori_eval/src/interpreter/panic.rs— PanicInfo construction - Ori Tests:
tests/spec/runtime/panic_info_construction.ori - LLVM Support: LLVM codegen for PanicInfo construction
- LLVM Rust Tests:
ori_llvm/tests/panic_tests.rs— PanicInfo construction codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Re-panic detection — immediate termination if handler panics
- Rust Tests:
ori_eval/src/interpreter/panic.rs— re-panic detection - Ori Tests:
tests/spec/runtime/panic_in_handler.ori - LLVM Support: LLVM codegen for re-panic detection
- LLVM Rust Tests:
ori_llvm/tests/panic_tests.rs— re-panic detection codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: First panic wins in concurrent context
- Rust Tests:
ori_eval/src/interpreter/panic.rs— concurrent panic handling - Ori Tests:
tests/spec/runtime/concurrent_panic.ori - LLVM Support: LLVM codegen for concurrent panic handling
- LLVM Rust Tests:
ori_llvm/tests/panic_tests.rs— concurrent panic codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Default handler (when no @panic defined) — print to stderr
- Rust Tests:
ori_eval/src/interpreter/panic.rs— default handler - Ori Tests:
tests/spec/runtime/default_panic_handler.ori - LLVM Support: LLVM codegen for default handler
- LLVM Rust Tests:
ori_llvm/tests/panic_tests.rs— default handler codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Exit with non-zero code after handler returns
- Rust Tests:
ori_eval/src/interpreter/panic.rs— exit code - LLVM Support: LLVM codegen for exit code handling
- LLVM Rust Tests:
ori_llvm/tests/panic_tests.rs— exit code codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
7A.7 Resource Management
Proposal: proposals/approved/drop-trait-proposal.md
Adds drop_early function for explicit early resource release.
drop_early Function
-
Implement:
drop_early<T>(value: T) -> void— Force drop before scope exit- Rust Tests:
ori_eval/src/function_val.rs— drop_early tests - Ori Tests:
tests/spec/stdlib/drop_early.ori - LLVM Support: LLVM codegen for drop_early
- LLVM Rust Tests:
ori_llvm/tests/drop_tests.rs— drop_early codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: drop_early works for any type (not restricted to T: Drop)
- Types with Drop: drop method called, then memory reclaimed
- Types without Drop: memory reclaimed immediately
- Ori Tests:
tests/spec/stdlib/drop_early_any_type.ori
-
Add to prelude: drop_early available without import
- Ori Tests:
tests/spec/prelude/drop_early.ori
- Ori Tests:
-
Update Spec:
spec/annex-c-built-in-functions.md— add drop_early documentation- Signature:
drop_early<T>(value: T) -> void - Semantics: Takes ownership, value is dropped immediately
- Use case: Release resources before scope exit
- Signature:
7A.8 Compile-Time File Embedding
PROPOSAL:
proposals/approved/embed-expression-proposal.md
embedandhas_embedbuilt-in expressions for compile-time file embedding. Type-driven:str(UTF-8 validated) or[byte](raw binary) based on expected type. Paths are const-evaluable expressions, relative to source file, restricted to project root.
-
Implement:
embed(path)— Compile-time file embedding- Context-sensitive keyword, parsed as
EmbedExprnode - Type-driven:
str→ UTF-8 read + validation,[byte]→ raw bytes - Path must be const-evaluable
str(supports interpolation, const functions) - Path resolution relative to source file, no absolute paths, no project escape
- Rust Tests:
ori_types/src/infer/expr/embed.rs— type inference for embed - Ori Tests:
tests/spec/embed/embed_str.ori,tests/spec/embed/embed_bytes.ori - LLVM Support: Emit embedded data in
.rodatasection - LLVM Rust Tests:
ori_llvm/tests/embed_tests.rs— embed codegen - AOT Tests: No AOT coverage yet
- Context-sensitive keyword, parsed as
-
Implement:
has_embed(path)— Compile-time file existence check- Returns compile-time
bool - Same path resolution rules as
embed - Rust Tests:
ori_types/src/infer/expr/embed.rs— has_embed type checking - Ori Tests:
tests/spec/embed/has_embed.ori - LLVM Support: LLVM codegen for has_embed
- LLVM Rust Tests:
ori_llvm/tests/embed_tests.rs— has_embed codegen - AOT Tests: No AOT coverage yet
- Returns compile-time
-
Implement: File size limit enforcement (10 MB default)
#embed_limit(size:)attribute for per-expression overrideori.toml[embed] max_file_sizefor project-wide override- Ori Tests:
tests/compile-fail/embed_size_limit.ori
-
Implement: File dependency tracking in Salsa
- Hash-based invalidation (content hash, not mtime)
- Embedded file changes trigger recompilation
has_embedfile existence changes trigger recompilation- Rust Tests:
oric/src/query/embed.rs— dependency tracking
-
Implement:
embed/has_embederror diagnostics — add error codes toori_diagnosticfor file-not-found, invalid path, bad UTF-8- File not found (with “did you mean?” suggestions)
- Absolute path error
- Path escapes project root error
- Invalid UTF-8 error (when
strexpected) - Cannot infer embed type error
- File exceeds size limit error
- Ori Tests:
tests/compile-fail/embed_errors.ori
-
Implement: Binary deduplication — multiple references to same file share one copy
- LLVM Rust Tests:
ori_llvm/tests/embed_tests.rs— deduplication - AOT Tests: No AOT coverage yet
- LLVM Rust Tests:
7A.9 Char and Byte Classification Methods
Proposal: proposals/approved/char-byte-classification-proposal.md
Standard classification methods on char and byte types for character category testing. char methods are Unicode-aware; byte methods are ASCII-only with short aliases.
Char Unicode Methods
- Implement:
char.is_alphabetic()— UnicodeL*categories- Rust Tests:
ori_types/src/infer/expr/methods/tests.rs— type resolution - Rust Tests:
ori_eval/src/methods/char/tests.rs— evaluation - Ori Tests:
tests/spec/types/char_classification.ori
- Rust Tests:
- Implement:
char.is_digit()— UnicodeNdcategory - Implement:
char.is_alphanumeric()—L*orNd - Implement:
char.is_whitespace()—Zs+ control whitespace - Implement:
char.is_uppercase()—Lu - Implement:
char.is_lowercase()—Ll - Implement:
char.is_ascii()— U+0000..U+007F - Implement:
char.is_control()—Cc - Implement: Unicode lookup tables from UCD — compressed tables for L*, Nd, Zs, Lu, Ll categories
Char ASCII Methods
- Implement:
char.is_ascii_alphabetic()—a-z,A-Z- Rust Tests:
ori_eval/src/methods/char/tests.rs— ASCII classification - Ori Tests:
tests/spec/types/char_ascii_classification.ori
- Rust Tests:
- Implement:
char.is_ascii_digit()—0-9 - Implement:
char.is_ascii_alphanumeric()—a-z,A-Z,0-9 - Implement:
char.is_ascii_whitespace()— space, tab, newline, CR, VT, FF - Implement:
char.is_ascii_uppercase()—A-Z - Implement:
char.is_ascii_lowercase()—a-z - Implement:
char.is_ascii_hex_digit()—0-9,a-f,A-F - Implement:
char.is_ascii_punctuation()— ASCII punctuation ranges - Implement:
char.is_ascii_control()— 0x00..0x1F, 0x7F
Byte Methods (Full + Short Aliases)
- Implement:
byte.is_ascii(),byte.is_ascii_alpha()/byte.is_alpha(),byte.is_ascii_digit()/byte.is_digit(), etc.- Rust Tests:
ori_types/src/infer/expr/methods/tests.rs— byte method type resolution - Rust Tests:
ori_eval/src/methods/byte/tests.rs— evaluation - Ori Tests:
tests/spec/types/byte_classification.ori
- Rust Tests:
- Implement: All 10 full byte methods + 7 short aliases — simple range checks, trivially inlineable
- LLVM Support: LLVM codegen for byte/char classification methods
- LLVM Rust Tests:
ori_llvm/tests/aot/primitives.rs— byte/char classification codegen - AOT Tests: No AOT coverage yet
- LLVM Rust Tests:
Conversion Methods
- Implement:
char.to_ascii_uppercase(),char.to_ascii_lowercase()— returns self if not ASCII letter- Ori Tests:
tests/spec/types/char_conversion.ori
- Ori Tests:
- Implement:
byte.to_ascii_uppercase(),byte.to_ascii_lowercase()— returns self if not ASCII letter- Ori Tests:
tests/spec/types/byte_conversion.ori
- Ori Tests:
- Implement:
char.to_digit(radix:),byte.to_digit(radix:)— returnsOption<int>; radix 2..=36, panic on invalid- Ori Tests:
tests/spec/types/char_to_digit.ori
- Ori Tests:
7A.10 Byte-Level String Access
Proposal: proposals/approved/byte-string-access-proposal.md
Methods for accessing raw UTF-8 bytes of a str value, enabling O(1) byte-level indexing for lexers and parsers.
str Methods
- Implement:
str.as_bytes()— zero-copy[byte]view via seamless slicing- Rust Tests:
ori_eval/src/methods/string/tests.rs— as_bytes evaluation - Ori Tests:
tests/spec/types/str_as_bytes.ori
- Rust Tests:
- Implement:
str.to_bytes()— owned[byte]copy- Ori Tests:
tests/spec/types/str_to_bytes.ori
- Ori Tests:
- Implement:
str.byte_len()— O(1) UTF-8 byte count- Ori Tests:
tests/spec/types/str_byte_len.ori
- Ori Tests:
- Implement: Flatten behavior —
as_bytes()on substring seamless slice produces single-level[byte]view
str Associated Functions
- Implement:
str.from_utf8(bytes:)— validate UTF-8, returnResult<str, Error>- Ori Tests:
tests/spec/types/str_from_utf8.ori
- Ori Tests:
- Implement:
str.from_utf8_unchecked(bytes:)— skip validation, requiresunsafe; unspecified-but-memory-safe on invalid input- Ori Tests:
tests/spec/types/str_from_utf8_unchecked.ori
- Ori Tests:
LLVM Support
- LLVM Support: Codegen for
as_bytes,to_bytes,byte_len,from_utf8,from_utf8_unchecked- LLVM Rust Tests:
ori_llvm/tests/aot/strings.rs— byte access codegen - AOT Tests: No AOT coverage yet
- LLVM Rust Tests:
7A.11 Section Completion Checklist
- All items above have all checkboxes marked
[ ] - Re-evaluate against docs/compiler-design/v2/02-design-principles.md
- 80+% test coverage, tests against spec/design
- Run full test suite:
./test-all.sh - LLVM Support: All LLVM codegen tests pass
Exit Criteria: Core built-in functions working correctly