Skip to content

c-migrate: goto-CFG memcpy path renders positional struct literals (invalid With) #746

Closed

Description

@ehartford

Repro

out/release/bin/with migrate out/test-graph/emit-c-smoke/emit_c_generic_intrinsics_case/generic_intrinsics.c \
  -o /tmp/small_mig.w -I $PWD/runtime -include $PWD/out/gen/wl_decls.h --no-c-export
out/release/bin/with check /tmp/small_mig.w

(Any prelude-bearing emitted C reproduces — the trigger is std.regex's
Regex struct flowing through the goto-CFG lowering.)

Actual

19 parse errors of this shape:

error: expected identifier
 --> small_mig.w:4128:112
4128 | with_memcpy((&raw mut __local__7__goto_1814_11 as *i8), (&raw const (Regex { __local__2__goto_1809_19, ((unsafe *__param__1)).pattern_text, ... } as Regex) as *i8), sizeof[Regex]())

The migrator renders a struct literal POSITIONALLY (Regex { a, b, c, ... })
inside the memcpy-of-aggregate form the goto-CFG path emits; With struct
literals require field names, so the emitted file does not parse.

Expected

Named-field literals (or a field-by-field store sequence). Loud failure if the
field names cannot be recovered.

Context

Pre-existing: byte-identical output from the pre-#744-fix compiler
(seed-archive d3d55c6) on the same input. This is the next fallout item for
the #740 roundtrip after #744's memory work: the emitted compiler C contains
the same std.regex code, so migrate-compiler-c will hit it once it can run to
completion.

Activity

  1. ehartford commented on Jul 31, 2026

    @ehartford
    ContributorAuthor

    Next on the roundtrip's critical path now that D28's ruling-3 pin (bdcb9b3) lets migrate-compiler-c run: the emitted compiler C contains std.regex, so the roundtrip hits this immediately after migration completes.

  2. ehartford commented on Jul 31, 2026

    @ehartford
    ContributorAuthor

    Fixed in e7bdd9c: the record-field queries hit the self-referential 'typedef struct X X;' decl first and returned empty without reaching the struct decl; the scan now continues past it, and both fixture Regex literals render fully named (minimal reduction checks clean). Positional fallback for records is now a loud per-function failure instead of invalid With — first construct that trips it is the payload-enum carrier shape, filed as #749, which is now the roundtrip's next critical-path item. Migrator basic/core lanes green on the fix.

  3. ehartford commented on Aug 31, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-08-31: CLOSE (overcome by events). Fixed by e7bdd9c — the goto-CFG memcpy path now renders named-field struct literals; migrated output checks with 0 errors.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions