Skip to content

Add std::prelude, auto-inject for all user ingots#1279

Merged
sbillig merged 3 commits intoargotorg:masterfrom
micahscopes:fe-prelude
Feb 25, 2026
Merged

Add std::prelude, auto-inject for all user ingots#1279
sbillig merged 3 commits intoargotorg:masterfrom
micahscopes:fe-prelude

Conversation

@micahscopes
Copy link
Collaborator

Summary

  • Create std::prelude module that re-exports core::prelude::* plus common EVM and ABI items
  • Change synthetic prelude injection from core::prelude::* to std::prelude::* for user ingots
  • Remove ~100 now-redundant import lines across test fixtures

What's in std::prelude

Item Source Usage in test fixtures
assert std::evm::effects::assert 97% of files
Abi, AbiEncoder, AbiSize, Encode core::abi 71% of files
Sol std::abi::Sol 71% of files
Evm std::evm::Evm 46% of files
Call std::evm::Call 40% of files
Address std::evm::Address 34% of files

Plus everything already in core::prelude (Clone, Copy, Default, Option, Result, etc.).

What's NOT in the prelude (still requires explicit import)

Ctx, StorageMap, Create, Log, low-level ops::*, mem, TStorPtr — these are common but not universal enough to warrant implicit availability.

Implementation

  • ingots/std/src/prelude.fe: new file, re-exports core::prelude + tier 1/2 items
  • crates/hir/src/core/lower/mod.rs: user ingots get std::prelude::*, std ingot still gets core::prelude::* (no self-import)
  • Snapshot updates: HIR desugar/pretty-print snapshots reflect std::prelude path, one CLI snapshot has shifted line numbers

Test plan

  • cargo build clean
  • cargo clippy --all-targets clean
  • cargo test — 546 tests pass, 0 failures

Closes #1228

@micahscopes
Copy link
Collaborator Author

@sbillig @cburgdorf @g-r-a-n-t

I have no strong opinions about this, please chime in or even push a change if you like

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00edc9da5c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@g-r-a-n-t
Copy link
Collaborator

I don't have strong opinions. Would just prefer to have it merged quickly.

@sbillig
Copy link
Collaborator

sbillig commented Feb 25, 2026

@g-r-a-n-t I'm adding Ctx, StorageMap, Create, Log, then will merge. <30 minutes.

micahscopes and others added 3 commits February 24, 2026 16:49
Create std::prelude that re-exports core::prelude plus common EVM/ABI
items that nearly every contract needs:

  - core::abi::{Abi, AbiEncoder, AbiSize, Encode} (71% of contracts)
  - std::abi::Sol (71%)
  - std::evm::{Evm, Address, Call, assert} (34-97%)

User ingots now get `use std::prelude::*` injected instead of
`use core::prelude::*`. The std ingot itself still gets core::prelude
(no self-import). This eliminates 2-4 boilerplate import lines from
the top of virtually every contract file.

Closes argotorg#1228
Instead of choosing between core::prelude or std::prelude, always
inject core::prelude as baseline and additionally inject std::prelude
for non-std ingots. If the std dependency lacks a prelude module (e.g.
a user-defined package aliased as "std"), the synthetic import fails
silently and core::prelude still provides Option, Result, etc.

This avoids the edge case where IngotKind::Std is assigned to
user-defined packages named "std" that don't actually have a prelude,
which would have silently dropped all implicit imports.
@sbillig sbillig merged commit 2cc6804 into argotorg:master Feb 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lib cleanup, std prelude

3 participants