Repository navigation
Conversation
added 4 commits
October 2, 2026 12:48
…: unsupported const kind 7
A CK_CLOSURE constant had no C lowering, so every closure — including the
loop-body closure D69 passes to a generator's each, and std.task's
gen_pull — failed with 'unsupported const kind 7'. Each closure is now a
static C function over its retained MIR body taking the context first,
with an env struct per closure: pointers to the creating frame's slots for
a non-move closure (D62: by place regardless of Copy), the environment
inline in the context word for a move closure of Copy captures that fit,
and an owned heap cell {drop_fn, clone_fn, env} otherwise — the tag bits
of CodegenDispatch.gen_closure. By-place and cell captures are indirect
locals and read as (*_N), as a value-ref parameter does.
Found while making the generator cells green, fixed at the source:
- fn types are named structurally: Sema gives a closure its own fn type,
and a typedef'd struct per tid made passing it to a structurally equal
parameter a C type error;
- a switch with no arms (D69's exit-code switch after a loop body that
neither breaks nor returns) emitted a bare else;
- the 'dead aggregate temp' skip dropped an aggregate built straight into
_0, so a gen fn's state constructor returned zeroes;
- a __sema__ specialization has no declaring module of its own: Sema now
records its template's (specialization_source_paths), and the C emitter
resolves sizeof[PullCore] in gen_pull's instance from std/task.w.
A closure coerced to a C function pointer and an async block fail loudly
naming the construct.
…#1766) The smoke's link line hard-coded fiber_stubs.o, so a program that pulls a generator aborted at its first next() ('needs the fiber runtime, which this program was linked without'). It now mirrors the native plan (link_stage_undefined_symbols_need_fiber_runtime): a with_fiber_ or with_channel_ reference on a non-extern line of the emitted C selects channel_runtime.o, fiber_runtime.o, fiber.o and fiber_asm.o; otherwise the stubs. The eight #1766 fixtures and the thirteen existing cases pass.
ehartford
force-pushed
the
fix-1766
branch
2 times, most recently
from
October 2, 2026 22:14
14def69 to
610b524
Compare
This was referenced Oct 2, 2026
Merged
Contributor
Author
|
Battery GREEN on stack top 7bdd704 (seed-driven, |
ehartford
marked this pull request as ready for review
October 2, 2026 22:30
This was referenced Oct 2, 2026
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 #1766. Eight fixtures under test/emit_c (no-capture, by-value Copy/str, view, mutating D62, stored+called twice, passed to fn, push generator
for v in nums(3),g.pull()) committed red (unsupported const kind 7), green after; each runs natively and as C with identical stdout via :emit-c-smoke (21 cases OK). Captures read Sema's facts (D65). Four defects fixed at the source: structural fn-type C names, empty-switchelse {, dead-aggregate-temp skipping a return-slot aggregate, specialization source paths for__sema__symbols. emit-c-smoke links the fiber runtime when referenced. Still unsupported, now loud with path:line: closure as a C fn pointer; async blocks. Gate green on 30f89aa.