Skip to content
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

feat: Debug::fmt for signed integers #5298

Closed
1 of 2 tasks
milancermak opened this issue Mar 20, 2024 · 0 comments · Fixed by #5308
Closed
1 of 2 tasks

feat: Debug::fmt for signed integers #5298

milancermak opened this issue Mar 20, 2024 · 0 comments · Fixed by #5308
Labels
enhancement New feature or request

Comments

@milancermak
Copy link
Contributor

Feature Request

Describe the Feature Request

It should be possible to print signed integers (i8...i128). Currently, trying to println!("{}", an_i128); results in an error similar to this

error: Trait has no implementation in context: core::fmt::Display::<core::integer::i128>
 --> /Users/m/projects/bibliodao/lordship/src/tests/test_velords.cairo[println_macro][writeln_macro]:3:31
    match core::fmt::Display::fmt(__write_macro_arg0__, ref __formatter_for_print_macros__) {
                              ^*^

Error: Failed to compile test artifact, for detailed information go through the logs above

Describe Preferred Solution

Both Debug and Display should be implemented. A sign should be prepended to the value in case it's negative.

Additional Context

scarb --version
scarb 2.6.3 (e6f921dfd 2024-03-13)
cairo: 2.6.3 (https://crates.io/crates/cairo-lang-compiler/2.6.3)
sierra: 1.5.0

Missing this feature also means it's currently not possible to use assert_eq! on signed integers.

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No
@milancermak milancermak added the enhancement New feature or request label Mar 20, 2024
@orizi orizi linked a pull request Mar 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant