Skip to content

ICE when setting a enum discriminator to an unsigned constant #2467

Closed

Description

@msullivan

Trying to compile:

enum test { thing = 3u }
fn main() {
    log(error, thing as int);
    assert(thing as int == 3);
}

results in

nubs/unsigned-enum-ice.rs:1:20: 1:22 error: mismatched types: expected `int` but found `uint` (int vs uint)
nubs/unsigned-enum-ice.rs:1 enum test { thing = 3u }
                                                ^~
nubs/unsigned-enum-ice.rs:1:20: 1:22 error: expected signed integer constant
nubs/unsigned-enum-ice.rs:1 enum test { thing = 3u }
                                                ^~
error: internal compiler error: tag_variants: bad disr expr

It should just have the type errors without the ICE.

Activity

  1. lkuper commented on Jun 1, 2012

    @lkuper
    Contributor

    It might make sense to fix this at the same time as #1417.

  2. catamorphism commented on Jun 21, 2012

    @catamorphism
    Contributor

    This appears to have been magically fixed. I added the test case.

  3. pnkfelix commented on Jul 30, 2013

    @pnkfelix
    Contributor

    (not magic, by the way; see ba9c3eb )

  4. added a commit that references this issue on Sep 22, 2022
  5. added a commit that references this issue on Jun 19, 2025
  6. added 2 commits that reference this issue on Aug 21, 2026
    e4add45
    15f143f
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

    A-type-systemArea: Type systemI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions