Fixes #881.
This commit is contained in:
@@ -1835,6 +1835,30 @@ fn forbid_expect_into_opaque_type_from_data() {
|
||||
))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_expect_into_type_from_data() {
|
||||
let source_code = r#"
|
||||
fn bar(n: Data) {
|
||||
expect a: Option<Int> = n
|
||||
a
|
||||
}
|
||||
"#;
|
||||
|
||||
assert!(check(parse(source_code)).is_ok())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_expect_into_type_from_data_2() {
|
||||
let source_code = r#"
|
||||
fn bar(n: Data) {
|
||||
expect Some(a): Option<Int> = n
|
||||
a
|
||||
}
|
||||
"#;
|
||||
|
||||
assert!(check(parse(source_code)).is_ok())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn forbid_expect_into_opaque_type_constructor_without_typecasting_in_module() {
|
||||
let source_code = r#"
|
||||
@@ -1985,6 +2009,19 @@ fn allow_expect_on_var_patterns_that_are_opaque() {
|
||||
assert!(check(parse(source_code)).is_ok())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_down_cast_to_data_always() {
|
||||
let source_code = r#"
|
||||
pub opaque type Foo { x: Int }
|
||||
pub fn bar(a: Foo) {
|
||||
let b: Data = a
|
||||
b
|
||||
}
|
||||
"#;
|
||||
|
||||
assert!(check(parse(source_code)).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn correct_span_for_backpassing_args() {
|
||||
let source_code = r#"
|
||||
|
||||
Reference in New Issue
Block a user