Closed
Description
I've had a hard time learning match
because this error message is misleading.
Steps to reproduce:
- Compile a small program which uses extra::json with
match value {
Number(n) => {
println(fmt!("%?\n", n))
},
_ => {
println(~"Doh")
}
}
- Note compiler error
Actual:
json.rs:20:25: 20:34 error: mismatched types: expected `&extra::json::Json` but found an enum or structure pattern
json.rs:20 Number(n) => {
^~~~~~~~~
error: aborting due to previous error
Expected:
error: mismatched types: expected `&extra::json::Json` but found enum extra::json::Json
or more generally
expected &someEnum but found enum T
Great work on the rest of the error message, BTW. I like the line number and arrow.
I eventually figured out that Number is an enum value of extra::json::Json and the fix is:
match value {
& Number(n) => {
println(fmt!("%?\n", n))
},
_ => {
println(~"Doh")
}
}