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

Proposal to always automatically import core into every Sway project #1781

Closed
emilyaherbert opened this issue May 31, 2022 · 3 comments
Closed

Comments

@emilyaherbert
Copy link
Contributor

The core library is what allows the compiler to handle operations like 1 + 2, true == false, etc. When the core library isn't listed as a dependency (or std isn't listed as a dependency, because it automatically brings in core), then the user gets a confusing error message about how core::ops::Add isn't imported, etc. I feel that because operations like 1 + 2 and true == false are so ubiquitous, that core should be automatically imported always. It also isn't a very good user experience to have to remember to import a library in order to use +, IMO.

@adlerjohn
Copy link
Contributor

Note that the only people that would be affected by this are us, since users are always expected to disable implicit std importing.

@tritao
Copy link
Contributor

tritao commented Jun 20, 2022

FWIW just hit this issue while trying to match an enum and was pretty confused at first what was going on.

21 | 
22 |     match(x) {
   |           ^ Module "core::ops" could not be found.
23 |         MyEnum::Point(x, y) => {
24 |         }

At the very least we should probably add to the error message here to mention that core needs to be imported.

@mohammadfawaz
Copy link
Contributor

This is complete. We have a pretty extensive core and std preludes now and Forc.toml imports std and core automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants