-
Notifications
You must be signed in to change notification settings - Fork 596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for otherwise pattern in match for enums #4557
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r1, all commit messages.
Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware and @TomerStarkware)
crates/cairo-lang-lowering/src/test_data/match
line 761 at r1 (raw file):
//! > lowering_diagnostics error: Enum variant `VariantId(test::Three)` not covered.
improve message
Code quote:
`VariantId(test::Three)`
6acecfe
to
5c6cc93
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware and @orizi)
crates/cairo-lang-lowering/src/test_data/match
line 761 at r1 (raw file):
Previously, orizi wrote…
improve message
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r2, all commit messages.
Reviewable status: 2 of 3 files reviewed, 2 unresolved discussions (waiting on @gilbens-starkware and @TomerStarkware)
crates/cairo-lang-lowering/src/lower/mod.rs
line 1121 at r2 (raw file):
let block_id = subscope.block_id; let arm_index = variant_map
report all missing variants.
crates/cairo-lang-lowering/src/lower/mod.rs
line 1255 at r2 (raw file):
Pattern::EnumVariant(PatternEnumVariant { inner_pattern: None, .. }) | Pattern::Otherwise(_) => Ok(()), _ => unreachable!(),
explain why in the macro string.
5c6cc93
to
ae27a56
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 3 files reviewed, 2 unresolved discussions (waiting on @gilbens-starkware and @orizi)
crates/cairo-lang-lowering/src/lower/mod.rs
line 1121 at r2 (raw file):
Previously, orizi wrote…
report all missing variants.
Done.
crates/cairo-lang-lowering/src/lower/mod.rs
line 1255 at r2 (raw file):
Previously, orizi wrote…
explain why in the macro string.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r3, all commit messages.
Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware and @TomerStarkware)
crates/cairo-lang-lowering/src/lower/mod.rs
line 1052 at r3 (raw file):
) -> LoweringResult<UnorderedHashMap<semantic::ConcreteVariant, usize>> { let mut map: UnorderedHashMap<_, _> = UnorderedHashMap::default(); for (arm_index, arm) in arms.enumerate() {
Suggestion:
/// Returns a map from variants to their corresponding arm index.
fn get_variant_to_arm_map<'a>(
ctx: &mut LoweringContext<'_, '_>,
arms: impl Iterator<Item = &'a semantic::MatchArm>,
concrete_enum_id: semantic::ConcreteEnumId,
) -> LoweringResult<UnorderedHashMap<semantic::ConcreteVariant, usize>> {
let mut map: UnorderedHashMap<_, _> = UnorderedHashMap::default();
for (arm_index, arm) in arms.enumerate() {
ae27a56
to
a001bf8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r4, all commit messages.
Reviewable status: 2 of 3 files reviewed, 4 unresolved discussions (waiting on @gilbens-starkware and @TomerStarkware)
crates/cairo-lang-lowering/src/lower/mod.rs
line 1051 at r4 (raw file):
concrete_enum_id: semantic::ConcreteEnumId, ) -> LoweringResult<UnorderedHashMap<semantic::ConcreteVariant, usize>> { let mut map: UnorderedHashMap<_, _> = UnorderedHashMap::default();
Suggestion:
let mut map = UnorderedHashMap::default();
crates/cairo-lang-lowering/src/lower/mod.rs
line 1109 at r4 (raw file):
let otherwise_variant = get_underscore_pattern_index(ctx, &expr.arms); let variant_map: UnorderedHashMap<_, _> = get_variant_to_arm_map( ctx,
Suggestion:
let variant_map = get_variant_to_arm_map(
ctx,
crates/cairo-lang-lowering/src/test_data/match
line 781 at r4 (raw file):
//! > ========================================================================== //! > Test match on enum tuples.
is this related to this pr?
crates/cairo-lang-lowering/src/test_data/match
line 788 at r4 (raw file):
//! > function fn foo(a: A,b: A) -> felt252 { match (a,b) {
format code
a001bf8
to
a6c91c1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r5, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @gilbens-starkware)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! all files reviewed, all discussions resolved (waiting on @gilbens-starkware)
crates/cairo-lang-lowering/src/lower/mod.rs
line 1051 at r4 (raw file):
concrete_enum_id: semantic::ConcreteEnumId, ) -> LoweringResult<UnorderedHashMap<semantic::ConcreteVariant, usize>> { let mut map: UnorderedHashMap<_, _> = UnorderedHashMap::default();
Done.
crates/cairo-lang-lowering/src/lower/mod.rs
line 1109 at r4 (raw file):
let otherwise_variant = get_underscore_pattern_index(ctx, &expr.arms); let variant_map: UnorderedHashMap<_, _> = get_variant_to_arm_map( ctx,
Done.
crates/cairo-lang-lowering/src/test_data/match
line 781 at r4 (raw file):
Previously, orizi wrote…
is this related to this pr?
no,removed
crates/cairo-lang-lowering/src/test_data/match
line 788 at r4 (raw file):
Previously, orizi wrote…
format code
removed
This change is