Skip to content

v2.2.0

Compare
Choose a tag to compare
@github-actions github-actions released this 23 Aug 11:31
· 1395 commits to main since this release
ad5570f

Breaking Changes

Bug Fixes

  • Avoid unnecessary struct reconstruction. #3739
  • Marked account contract trait with starknet interface. #3743
  • Fixed error message for missing gas. #3738
  • Fixed member usages under ifs in loops. #3770
  • Forbid error propagation inside a loop. #3773
  • Fixing snippets view fn without external by @gaetbout in #3857
  • Fix issues with self referential generics. #3879
  • Fix issue #3863. #3892

New Features

  • Formatter Improvements.
    • Better line breaks in recursive struct construction.
    • No extra space after commas at end of lines.
  • Language Server improvements.
    • Additional auto completions.
    • Additional goto definitions.
    • Better syntax highlighting.
  • ByteArray + String literals (Experimental: Cannot be used on starknet).
  • Signed Integers (Experimental: Cannot be used on starknet).
  • Added estimated gas to test result. #3709
  • Added default impl for tuples up to size 4. #3742
  • Added ecdsa recovery. #3735
  • Made error message for entry point be dependent on failing var. #3740
  • derive Serde for BlockInfo/TxInfo by @enitrat in #3781
  • Add option for sorting imports in formatter by @ericnordelo in #3778
  • Refactored Hash trait, hash implementation is now generic. #3714
  • snippets use array! by @gaetbout in #3814
  • Added PartialEq impl for Array. #3812
  • Add pop_l2_to_l1_message cheatcode by @0xChqrles in #3783
  • Nullable new method by @enitrat in #3841
  • Added line number to sierra printing. #3902
  • Made inline macros pluginable. #3873
  • Named generic arguments. #3903
  • Added derive for Default trait. #3935
  • Added derive for Hash trait. #3936
  • Added inline macro selector!("entry_point_name") for starknet, that returns the corresponding numeric value of the entry point selector.

Diagnostics Improvements.

code:

#[derive(Copy)]
struct ACopy {}
#[derive(Drop)]
struct ADrop {}
fn use_a_copy(x: ACopy) { .. }
fn use_a_drop(x: ADrop) { .. }

fn foo(x: ACopy, y: ADrop) -> ADrop {
  if true {
    use_a_copy(x);
    use_a_drop(y);
  } else {
  }
  y
}

diagnostics:

error: Variable was previously moved.
 --> lib.cairo:14:3
  y
  ^
note: variable was previously used here:
  --> lib.cairo:11:16
    use_a_drop(y);
               ^
note: Trait has no implementation in context: core::traits::Copy::<test::ADrop>

error: Variable not dropped.
 --> lib.cairo:8:8
fn foo(x: ACopy, y: ADrop) -> ADrop {
       ^
+note: the variable needs to be dropped due to the divergence here:
+  --> lib.cairo:9:3
+  if true {
+  ^*******^
note: Trait has no implementation in context: core::traits::Drop::<test::ACopy>
note: Trait has no implementation in context: core::traits::Destruct::<test::ACopy>

code:

struct A {}
fn foo(ref a: A) {
   1 + 1;
}

diagnostics:

error: Variable not dropped.
 --> lib.cairo:2:12
fn foo(ref a: A) {
           ^
+note: the variable needs to be dropped due to the potential panic here:
+  --> lib.cairo:3:4
+   1 + 1;
+   ^***^
note: Trait has no implementation in context: core::traits::Drop::<test::A>
note: Trait has no implementation in context: core::traits::Destruct::<test::A>

code:

struct NonCopy {}
struct MyStruct {
  a: felt252,
  b: NonCopy,
}

fn foo(mut x: MyStruct) -> MyStruct {
  x.a = 17;
  x.a += 1;
  return x;
}

diagnostics:

error: Variable not dropped.
- --> lib.cairo:10:3
-  x.a = 17;
-  ^*^
+ --> lib.cairo:9:12
+fn foo(mut x: MyStruct) -> MyStruct {
+           ^
+note: the variable needs to be dropped due to the potential panic here:
+  --> lib.cairo:11:3
  x.a += 1;
  ^******^
note: Trait has no implementation in context: core::traits::Drop::<test::NonCopy>
note: Trait has no implementation in context: core::traits::Destruct::<test::NonCopy>

Optimizations

  • Statement reorder and remove unused not only for literals. #3696
  • Improve encode/decode implementation. #3800
  • Faster compile time generally (Various optimizations)

Others

New Contributors

Full Changelog: v2.1.1...v2.2.0