cairo icon indicating copy to clipboard operation
cairo copied to clipboard

feat: add `self` keyword to import a module

Open enitrat opened this issue 10 months ago • 5 comments

Feature Request

Describe the Feature Request

Currently when testing my contracts, to test the assertions of events, I might need to import the contract and it's internal content, like:

use registry::Registry
use registry::Registry::{
    DataRegistered, DataUpdated
};

Registry here is a contract module. I would like to be able to write:

use registry::Registry::{
    self, DataRegistered, DataUpdated
};

enitrat avatar Feb 13 '25 23:02 enitrat

hey assign this to me

g4titanx avatar Feb 15 '25 14:02 g4titanx

duplicate: #3344

itzlambda avatar Feb 16 '25 18:02 itzlambda

Can I tackle this one?

ryzen-xp avatar Feb 19 '25 06:02 ryzen-xp

@g4titanx If you want to tackle this, please update.

In general this should be done by updating crates/cairo-lang-semantic/src/resolve/mod.rs to handle self as a leaf during the resolution of a path.

orizi avatar Feb 27 '25 10:02 orizi

@g4titanx If you want to tackle this, please update.

In general this should be done by updating crates/cairo-lang-semantic/src/resolve/mod.rs to handle self as a leaf during the resolution of a path.

i made a PR already, please review

g4titanx avatar Feb 27 '25 12:02 g4titanx

hey any updates?

enitrat avatar Mar 31 '25 13:03 enitrat

I'm still not convinced this is so helpful. but attached PR.

orizi avatar Mar 31 '25 15:03 orizi

bounded ints are more useful than this 😄

feltroidprime avatar Mar 31 '25 20:03 feltroidprime