Skip to content

ICE when initializing an array in macro expansion #23232

Closed

Description

@gkoz
trait Foo { fn foo(&self); }

macro_rules! foo {
    () => ();
    ($a:expr, $($n:expr,)*) => (
        impl Foo for [(); $a] {
            fn foo(&self) {
                // Okay
                let baz: [i32; $a] = [$($n),*];
                // ICE
                let bar = [$($n),*];
            }
        }
        foo!($($n,)*);
    )
}

foo!(3, 2, 1, 0,);

fn main() {}
<anon>:11:27: 11:36 error: internal compiler error: cat_expr Errd
<anon>:11                 let bar = [$($n),*];
                                    ^~~~~~~~~
rustc 1.0.0-nightly (91bdf23f5 2015-03-09) (built 2015-03-09)

Activity

  1. rprichard commented on Mar 9, 2015

    @rprichard
    Contributor

    let bar = []; is enough to make it ICE. This test case does not ICE if I prepend 0, to the bar initializer, so I think this issue is a duplicate of #22897.

  2. gkoz commented on Mar 9, 2015

    @gkoz
    ContributorAuthor

    @rprichard
    Indeed. I'll close this one then.

  3. added a commit that references this issue on Aug 31, 2026
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