Skip to content

internal compiler error: literals of different types in range pat #27895

Closed
@steveklabnik

Description

@steveklabnik

code:

fn main() {
    let i = 5;
    let index = 6;

    match i {
        0...index => println!("winner"),
        _ => println!("hello"),
    }
}

backtrace:

$ RUST_BACKTRACE=1 rustc hello.rs 
hello.rs:6:13: 6:18 error: paths in constants may only refer to constants or functions [E0014]
hello.rs:6         0...index => println!("winner"),
                       ^~~~~
hello.rs:6:13: 6:18 help: run `rustc --explain E0014` to see a detailed explanation
hello.rs:6:13: 6:18 error: non-constant path in constant expr
hello.rs:6         0...index => println!("winner"),
                       ^~~~~
hello.rs:6:9: 6:13 error: internal compiler error: literals of different types in range pat
hello.rs:6         0...index => println!("winner"),
                   ^~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/diagnostic.rs:176

stack backtrace:
   1:     0x7f9d70393719 - sys::backtrace::write::h0942de78b6c02817K8r
   2:     0x7f9d7039b5a6 - panicking::on_panic::h3f23f9d0b5f4c91bu9w
   3:     0x7f9d7036168e - rt::unwind::begin_unwind_inner::h2844b8c5e81e79558Bw
   4:     0x7f9d6d36f717 - rt::unwind::begin_unwind::h18145712027808195836
   5:     0x7f9d6d36f6d6 - diagnostic::SpanHandler::span_bug::h8e44e4841a51abaeu0A
   6:     0x7f9d6e250e03 - session::Session::span_bug::h40e3119864c3d8a1K2v
   7:     0x7f9d6e354b0e - middle::check_const::CheckCrateVisitor<'a, 'tcx>.Visitor<'v>::visit_pat::h6220fb348036755bh2f
   8:     0x7f9d6e35b9de - visit::walk_arm::h9955704895933812950
   9:     0x7f9d6e35b7f9 - visit::walk_expr::h7697329746255857751
  10:     0x7f9d6e353690 - middle::check_const::CheckCrateVisitor<'a, 'tcx>.Visitor<'v>::visit_expr::h5783870ff6525954l6f
  11:     0x7f9d6e35543a - middle::check_const::CheckCrateVisitor<'a, 'tcx>.Visitor<'v>::visit_block::h2558554741ed8af783f
  12:     0x7f9d6e3541a9 - middle::check_const::CheckCrateVisitor<'a, 'tcx>::fn_like::closure.85964
  13:     0x7f9d6e353df4 - middle::check_const::CheckCrateVisitor<'a, 'tcx>::fn_like::hc56dcd308c93859dAMf
  14:     0x7f9d6e358987 - visit::walk_item::h14267295391074712870
  15:     0x7f9d6e3585d0 - middle::check_const::CheckCrateVisitor<'a, 'tcx>.Visitor<'v>::visit_item::hbb7119ce9457c5c8NWf
  16:     0x7f9d6e36158a - middle::check_const::check_crate::hcb43feb691c60b59xDg
  17:     0x7f9d708de050 - driver::phase_3_run_analysis_passes::closure.20596
  18:     0x7f9d708bce05 - middle::ty::ctxt<'tcx>::create_and_enter::h9049188843559879450
  19:     0x7f9d708b7f5d - driver::phase_3_run_analysis_passes::h10313786347949334605
  20:     0x7f9d7089b676 - driver::compile_input::h68da15dd21986404Tba
  21:     0x7f9d70a067eb - run_compiler::h707077bbe9100331Obc
  22:     0x7f9d70a040b7 - boxed::F.FnBox<A>::call_box::h6790869519760498004
  23:     0x7f9d70a03b24 - rt::unwind::try::try_fn::h1844525071116418565
  24:     0x7f9d7039b148 - __rust_try
  25:     0x7f9d70387a62 - rt::unwind::try::inner_try::h45702ba1ad1620941xw
  26:     0x7f9d70a03cb8 - boxed::F.FnBox<A>::call_box::h11351074772415591031
  27:     0x7f9d7039a593 - sys::thread::Thread::new::thread_start::h66ead7b2912d4f30OHv
  28:     0x7f9d69fae0a3 - start_thread
  29:     0x7f9d7001d04c - clone
  30:                0x0 - <unknown>

rustc:

rustc 1.4.0-nightly (e35fd7481 2015-08-17)

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions