Skip to content

Comptime: str.trim/index_of/to_upper/to_lower/repeat evaluate; an action failure names its line; generic calls without type args read Sema's specialization (#1866) - #1891

Merged
ehartford merged 7 commits into
fix-cfnfrom
fix-comptime-str
Sep 29, 2026
Merged

ehartford merged 7 commits into
fix-cfnfrom
fix-comptime-str

Conversation

@ehartford

@ehartford ehartford commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Stack #1898, layer 6. Closes #1866. build/seed.w's seed_lock_value needed str.trim in the comptime evaluator; :seed failed whenever the native runner was unusable. Also: cli-selfhost-build-w-tests runs a printing action and this tree's :seed under the comptime driver. Draft until the stack battery is green and posted.

@ehartford
ehartford added this pull request to stack #1898 September 29, 2026 05:03
@ehartford ehartford changed the title fix comptime str Comptime: str.trim/index_of/to_upper/to_lower/repeat evaluate; an action failure names its line; generic calls without type args read Sema's specialization (#1866) Sep 29, 2026
Eric Hartford added 7 commits September 29, 2026 14:40
…1866)

The evaluator is the bootstrap path: it runs every build action whenever
the native runner cannot be linked yet (`:seed`, any `--no-deps` action in
a fresh checkout, #1797). build/seed.w's seed_lock_value trims every lock
line, so `src/main build :seed` in such a checkout failed with "str method
'trim' is not comptime-evaluable yet". eval_str_method_call now covers the
rest of MirLower's str intrinsic set through the same runtime helpers
codegen calls, so comptime and runtime agree byte for byte.

test/comptime_diff/cd_str.w gains a second battery over the five methods
(whitespace, a missing needle, repeat(0)); it failed under the pinned seed
at `s.trim()` and passes under stage1.
The build driver prints the evaluator's error_msg alone; the pending
diagnostic with the span is emitted into Sema's list and never rendered
there, so "generic comptime function expects 1 type argument(s), found 0"
over a 300-line action named nothing (#1804 sat unlocated for that
reason). fail() now prefixes the message with path:line:col of the node
in the current module, computed through Source.offset_to_location.
…'s inferred specialization (#1866, #1804)

D55 made print and eprint generic (print[T: Display](v: &T)), and the
evaluator demanded explicit type arguments for every generic free call, so
every build action that prints failed under the evaluator with "generic
comptime function expects 1 type argument(s), found 0" — the
embedded-clang-resource-source failure at build/clang_resource.w:295 and
#1804's pcre2 actions (the seed only "evaluated them green" when the
native runner ran them). eval_fn_symbol_call_values_with_type_args now
resolves an unspelled generic call the way eval_user_method_value resolves
a generic method: Sema's resolved_call_sigs entry for the call node, or
check_generic_call when fold order reaches the call first, then the
concrete specialization's substitutions (D65: Sema infers, the evaluator
reads). Explicit `f[T](x)` calls are unchanged.

Under stage1 with the runner refused (a foreign-generation out/lib),
`build :seed --no-deps` prints "src/main is the pinned seed" and
`build :embedded-clang-resource-source --no-deps` generates the 49-header
resource file; both failed before.

Fixes #1866
Fixes #1804
…e's :seed under the comptime evaluator; a census of the build layer's method calls (#1866)

bs_check_build_w_comptime_evaluator forces the evaluator the way #1797's
gate does (an empty cimport_stubs.o in the case's out/lib refuses the
runner, no second compiler needed) and runs two cases with the release
compiler: a build.w action that prints a literal and f-strings and spells
trim/index_of/to_upper/to_lower/repeat, asserting the outputs and that no
runner was compiled; and a copy of this tree's build layer running
`build :seed --no-deps` against the pinned src/main, asserting "is the
pinned seed". The second is the exact failure that opened #1866.

tools/comptime_build_census.w lists every `.name(` the build layer spells
(Lexer-based), with call counts, and classes each as an evaluator arm, a
build-layer or stdlib user method, or MISSING. It reads 167 names and 0
missing after this batch; `--missing` prints only the gaps.

build.w's embedded-clang-resource-source comment no longer claims the
evaluator cannot run the action.
…ce through resolve_path like every other read

lib/std/build.w:1683, :1724 and :1730 ran tool_path_require_project_relative
on the spelled source path before project_relative_path had stripped the
project root, so an absolute path inside the project (the runner's
ctx.project_info().project_root() joined with build.w) was refused as
'escapes project root' while read_text, exists and write_text, which go
through resolve_path, accept it — and the comptime evaluator's arms
(capability_resolve_project_path) strip the root first and accepted it
too. The battery's cli-selfhost-build-w-tests ran the new evaluator-seed
case under the native runner and failed on the first copy_file. The
raw pre-check was a second derivation of one rule: resolve_path already
strips the root and then requires a project-relative path, so the three
methods now rely on it; a path outside the root or one with .. is refused
exactly as before.
… before copying workflows (#1866)

bs_check_build_w_comptime_evaluator copies this tree's build layer into a
case directory and runs build :seed --no-deps there. build.w's graph
function reads src/version before any target runs (build.w:2240), so the
copy panicked in read_text; and rt_copy_tree makes only its own
destination directory, so copying .github/workflows into a case with no
.github failed with ENOENT. The case now copies src/version and creates
.github first.
…ths, which every seed's ToolFs accepts

The case passed absolute paths (project_root()/build.w); the ToolFs fix
that resolves an absolute in-root source (9ca8f8df) is std.build, so a
runner the pinned seed compiles still refuses them: "ToolFs path escapes
project root" in the stack battery. A project-relative source resolves to
the same file under every seed, and a relative symlink target resolves to
the same absolute link. 9ca8f8df stays and applies at the next seed.
@ehartford
ehartford marked this pull request as ready for review September 29, 2026 18:57
@ehartford
ehartford merged commit 1f135b9 into main Sep 29, 2026
@ehartford
ehartford deleted the fix-comptime-str branch September 29, 2026 19:03
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.

comptime evaluator: str.trim (build/seed.w seed_lock_value) is not evaluable, so :seed fails whenever the native runner is not usable

1 participant