Skip to content

ICE with pattern guards #2869

Closed
Closed

Description

@catamorphism

This code causes an ICE in trans::alt::compile_submatch (where it calls option::get):

enum pat { pat_ident(option<uint>) }

fn f(pat: pat) -> bool { true }

fn num_bindings(pat: pat) -> uint {
    alt pat {
      pat_ident(_) if f(pat) { 0 }
      pat_ident(none) { 1 }
      pat_ident(some(sub)) { sub }
    }
}

fn main() {}

I've tried to fix it, but I just don't understand the code that compiles pattern matches. Comments would be helpful.

Activity

  1. added a commit that references this issue on Jul 11, 2012
  2. bblum commented on Jul 16, 2012

    @bblum
    Contributor

    We ran into a similar patterning ICE during ICFP (#2928), when doing disjunctive patterns with different variable names, I think? (i.e., "foo(a) | bar(b) { .. }") efaust determined the code was incorrect and the compiler should've errored, and it won't ICE on correct code.

    Hopefully related. Tarball forthcoming.

  3. catamorphism commented on Jul 16, 2012

    @catamorphism
    ContributorAuthor

    If it doesn't ICE on correct code, then you found a different bug, because the code above is correct.

  4. catamorphism commented on Dec 8, 2012

    @catamorphism
    ContributorAuthor

    This is indeed a dup of #3121.

  5. removed their assignment
    on Jun 16, 2014
  6. added a commit that references this issue on May 11, 2023
  7. added a commit that references this issue on May 30, 2026
  8. added a commit that references this issue on Aug 21, 2026
    de24097
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-codegenI-crash

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions