We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Option
match
Cairo version:
scarb 2.9.2+nightly-2024-12-22 (29eda693a 2024-12-22) cairo: 2.9.2 (b356014ef) sierra: 1.6.0
Current behavior:
When setting an alias for Option, like:
type OptAlias<T> = Option<T>;
One is able to assign a value of this alias type using the Alias name like:
let opt_alias: OptAlias<u32> = OptAlias::None;
But matching against this alias using the alias name fails with "Invalid Path":
let opt_alias: OptAlias<u32> = OptAlias::None; match opt_alias { OptAlias::None => println!("opt_alias is None"), // Error: Invalid path. OptAlias::Some(val) => println!("opt_alias is Some({val})"), // Error: Invalid path. }
Instead, one has to use Option directly:
let opt_alias: OptAlias<u32> = OptAlias::None; match opt_alias { Option::None => println!("opt_alias is None"), // works Option::Some(val) => println!("opt_alias is Some({val})"), // works }
Expected behavior:
One should be able to use alias name in the match.
Steps to reproduce:
Related code:
type OptAliasU32 = Option<u32>; type OptAlias<T> = Option<T>; fn main() { let opt: Option<u32> = Option::None; match opt { Option::None => println!("opt is None"), Option::Some(val) => println!("opt is Some({val})"), } let opt_alias: OptAliasU32 = OptAliasU32::None; match opt_alias { Option::None => println!("opt_alias is None"), // works Option::Some(val) => println!("opt_alias is Some({val})"), // works } let opt_alias: OptAlias<u32> = OptAlias::None; match opt_alias { Option::None => println!("opt_alias is None"), // works Option::Some(val) => println!("opt_alias is Some({val})"), // works } let opt_alias: OptAliasU32 = OptAliasU32::None; match opt_alias { OptAliasU32::None => println!("opt_alias is None"), // Invalid path. OptAliasU32::Some(val) => println!("opt_alias is Some({val})"), // Invalid path. } let opt_alias: OptAlias<u32> = OptAlias::None; match opt_alias { OptAlias::None => println!("opt_alias is None"), // Invalid path. OptAlias::Some(val) => println!("opt_alias is Some({val})"), // Invalid path. } }
Other information:
The text was updated successfully, but these errors were encountered:
dean-starkware
No branches or pull requests
Bug Report
Cairo version:
Current behavior:
When setting an alias for
Option
, like:One is able to assign a value of this alias type using the Alias name like:
But matching against this alias using the alias name fails with "Invalid Path":
Instead, one has to use
Option
directly:Expected behavior:
One should be able to use alias name in the
match
.Steps to reproduce:
Related code:
Other information:
The text was updated successfully, but these errors were encountered: