File tree Expand file tree Collapse file tree
crates/cairo-lang-semantic/src/expr/test_data Expand file tree Collapse file tree Original file line number Diff line number Diff line change 439439//! > module_code
440440
441441//! > expected_diagnostics
442+
443+ //! > ==========================================================================
444+
445+ //! > Test invalid patterns on Span value.
446+
447+ //! > test_runner_name
448+ test_function_diagnostics(expect_diagnostics: true)
449+
450+ //! > function_code
451+ fn foo(s: Span<u32>) -> u32 {
452+ match s {
453+ [a, b] => *a + *b,
454+ 5 => 0,
455+ (a, b) => *a + *b,
456+ Some(a) => *a,
457+ }
458+ }
459+
460+ //! > function_name
461+ foo
462+
463+ //! > module_code
464+
465+ //! > expected_diagnostics
466+ error[E2103]: Mismatched types: pattern cannot match against type "core::array::Span::<core::integer::u32>".
467+ --> lib.cairo:5:9
468+ (a, b) => *a + *b,
469+ ^^^^^^
470+
471+ error[E2135]: Type `<missing>` cannot be dereferenced
472+ --> lib.cairo:5:19
473+ (a, b) => *a + *b,
474+ ^
475+
476+ error[E2135]: Type `<missing>` cannot be dereferenced
477+ --> lib.cairo:5:24
478+ (a, b) => *a + *b,
479+ ^
480+
481+ error[E2103]: Mismatched types: pattern cannot match against type "core::array::Span::<core::integer::u32>".
482+ --> lib.cairo:6:9
483+ Some(a) => *a,
484+ ^^^^^^^
485+
486+ error[E0006]: Identifier not found.
487+ --> lib.cairo:6:21
488+ Some(a) => *a,
489+ ^
490+
491+ error[E2135]: Type `<missing>` cannot be dereferenced
492+ --> lib.cairo:6:20
493+ Some(a) => *a,
494+ ^
495+
496+ error[E2311]: Mismatched types. The type `core::array::Span::<core::integer::u32>` cannot be created from a numeric literal.
497+ --> lib.cairo:4:9
498+ 5 => 0,
499+ ^
You can’t perform that action at this time.
0 commit comments