Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

rp2xxx: `pio.assembler.Output.get_define_by_name` does not compile (declared `u32`, breaks with a `Define`)

オープン 初心者向け
#1,086 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
zig
領域
embedded-iot

調査の方向性

port/raspberrypi/rp2xxx/src/hal/pio/assembler.zigで、Output.get_define_by_nameとそのDefine型の周辺を読んでください。issueには回帰テストの例が含まれています。T1の検索をテストするケースを追加し、port/raspberrypi/rp2xxxでzig build testを実行してください。関数がコンパイルされ、定義の値を返し、テストが成功すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Summary

Output.get_define_by_name (port/raspberrypi/rp2xxx/src/hal/pio/assembler.zig:58-66 on
master) is declared to return u32, but its loop does break define;, which is a
Define{ name, value: i64 }. Every call fails inside the package:

assembler.zig:64:23: error: expected type 'u32', found 'hal.pio.assembler.Define'

Nothing in the tree calls it (grep -rn get_define_by_name finds only the
declaration), so CI never compiles it. The function has been in this shape since at
least 185e906e5 (2024-02-25). Users who want a define by name end up indexing
.defines[i] by position, and that silently reads the wrong constant once the
program's .define lines are reordered.

Versions
tree toolchain result
microzig 0.15.1 release zig 0.15.2 compile error (rc=1), assembler.zig:66:23
microzig master f36d59fb7b22 (tag 0.17.17, 2026-10-10) zig 0.17.0 compile error (rc=1), assembler.zig:64:23
master + the fix below zig 0.17.0 builds (rc=0)
Repro

A minimal firmware with microzig as a path dependency, built for boards.raspberrypi.pico:

const microzig = @import("microzig");
const hal = microzig.hal;

const out = hal.pio.assemble(
    \\.define PUBLIC T1 3
    \\.program p
    \\    nop
, .{});

comptime {
    if (@hasDecl(microzig, "export_startup")) _ = microzig.export_startup();
}

pub fn main() void {
    const t1 = comptime out.get_define_by_name("T1");
    if (t1 != 3) @compileError("expected T1 == 3");
    while (true) {}
}

Expected: builds; T1 == 3.
Actual (master, zig 0.17.0):

deps/microzig/port/raspberrypi/rp2xxx/src/hal/pio/assembler.zig:64:23: error: expected type 'u32', found 'hal.pio.assembler.Define'
                break define;
                      ^~~~~~
repro.zig:18:47: note: called at comptime here
    const t1 = comptime out.get_define_by_name("T1");
Fix

Return the define's value, typed as Define.value is (i64), so no cast or range
check is needed. The patch also adds a test, so CI compiles the function from now on:

-    ) u32 {
+    ) i64 {
         return for (output.defines) |define| {
             if (std.mem.eql(u8, name, define.name))
-                break define;
+                break define.value;
test "get_define_by_name" {
    const output = comptime assemble(.RP2040,
        \\.define PUBLIC T1 3
        \\.program testprog
        \\    nop
    , .{});
    try std.testing.expectEqual(@as(i64, 3), comptime output.get_define_by_name("T1"));
}

zig build test in port/raspberrypi/rp2xxx: master gives 135/135 passed; with the
patch it gives 136/136 passed (rc=0).

(Alternative, if you would rather mirror get_program_by_name: return Define
and have callers write .value. The patch keeps the name's promise of a value.)

I have the patch ready and can open it as a PR if you'd like.

主要言語
Zig
スター
2.3k
フォーク
198
平均マージ
1日 8時間
マージ済み PR(30日)
37

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ZigEmbeddedGroup/microzig のほかの issue

ZigEmbeddedGroup/microzig の issue をすべて見る

似ている issue

Embedded & IoT の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。