doc: fix match-expressions.adoc to cover all supported match targets#9759
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
orizi
left a comment
There was a problem hiding this comment.
@orizi made 2 comments.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on eytan-starkware and TomerStarkware).
docs/reference/src/components/cairo/modules/language_constructs/pages/match-expressions.adoc line 31 at r1 (raw file):
==== == Supported match targets
should probably mention recursive matching as well - but maybe not for this PR.
docs/reference/src/components/cairo/modules/language_constructs/pages/match-expressions.adoc line 53 at r1 (raw file):
Match expressions also work on `felt252`, integer types (`u8`, `u16`, `u32`, `u64`, `u128`, `i8`, `i16`, `i32`, `i64`, `i128`), `bool`, and short string literals (which are `felt252` values).
short string literals are simply other ways to write numeric value - of all types - not specifically felt252 but for that reason - should probably not be mentioned here at all.
98a53ca to
60c9b52
Compare
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on eytan-starkware).
docs/reference/src/components/cairo/modules/language_constructs/pages/match-expressions.adoc line 57 at r2 (raw file):
[source, cairo] ---- // Match on felt252
I don't think this is different from integers should just be numeric values,
If you still want to keep it, add a 1 case as it is now supported.
60c9b52 to
92ccca0
Compare
bea8cd2 to
54a1800
Compare
09c04ab to
2710d6c
Compare
eytan-starkware
left a comment
There was a problem hiding this comment.
@eytan-starkware made 3 comments.
Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on orizi and TomerStarkware).
docs/reference/src/components/cairo/modules/language_constructs/pages/match-expressions.adoc line 31 at r1 (raw file):
Previously, orizi wrote…
should probably mention recursive matching as well - but maybe not for this PR.
Done.
docs/reference/src/components/cairo/modules/language_constructs/pages/match-expressions.adoc line 53 at r1 (raw file):
Previously, orizi wrote…
short string literals are simply other ways to write numeric value - of all types - not specifically
felt252but for that reason - should probably not be mentioned here at all.
Done.
docs/reference/src/components/cairo/modules/language_constructs/pages/match-expressions.adoc line 57 at r2 (raw file):
Previously, TomerStarkware wrote…
I don't think this is different from
integersshould just be numeric values,
If you still want to keep it, add a1case as it is now supported.
Done.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2710d6c7a1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
docs/reference/src/components/cairo/modules/language_constructs/pages/match-expressions.adoc
Outdated
Show resolved
Hide resolved
orizi
left a comment
There was a problem hiding this comment.
@orizi resolved 2 discussions.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on eytan-starkware and TomerStarkware).
2710d6c to
5558cac
Compare
eytan-starkware
left a comment
There was a problem hiding this comment.
@eytan-starkware made 1 comment.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on TomerStarkware).
docs/reference/src/components/cairo/modules/language_constructs/pages/match-expressions.adoc
Outdated
Show resolved
Hide resolved
eytan-starkware
left a comment
There was a problem hiding this comment.
@eytan-starkware resolved 1 discussion.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on TomerStarkware).
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 1 file and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

Summary
Expanded the match expressions documentation to include support for numeric types (
u8,u16,u32,u64,u128,i8,i16,i32,i64,i128),bool, and short string literals, in addition to the previously documentedenumandfelt252support. Added concrete code examples for integer and boolean matching patterns.Type of change
Please check one:
Why is this change needed?
The documentation was incomplete and potentially misleading by stating that only two kinds of match expressions were supported (enum and felt252), when in fact Cairo's match expressions work with a broader range of types including all integer types, booleans, and short string literals. This omission could cause developers to unnecessarily avoid using match expressions with these supported types.
What was the behavior or documentation before?
The documentation claimed that "Currently two kinds of match expression are supported" and only showed examples for enum and felt252 matching, with no mention of integer types, booleans, or short string literals.
What is the behavior or documentation after?
The documentation now accurately describes that match expressions support enums, felt252, all integer types (u8-u128, i8-i128), bool, and short string literals, with practical code examples demonstrating integer and boolean matching patterns.
Related issue or discussion (if any)
Additional context
This change helps developers understand the full capabilities of Cairo's match expressions, enabling them to write more idiomatic and readable code when working with numeric and boolean values.
Note
Low Risk
Low risk documentation-only update; main risk is minor confusion if examples or type lists are inaccurate.
Overview
Updates
match-expressions.adocto replace the “two kinds supported” limitation with a broader Supported match targets section.Documents matching on numeric integer types and
boolwith new examples and notes about wildcard arm ordering, and adds coverage for struct/tuple destructuring,|OR patterns (including variable-binding consistency), and nested/recursive pattern matching, plus a new See also link section.Reviewed by Cursor Bugbot for commit 5558cac. Bugbot is set up for automated code reviews on this repo. Configure here.