Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Cannot compile due to errors in types/i256.rs #2486

Open
coffeeavax opened this issue Jun 29, 2023 · 1 comment
Open

Cannot compile due to errors in types/i256.rs #2486

coffeeavax opened this issue Jun 29, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@coffeeavax
Copy link

Version
│ ├── ethers v2.0.7
│ │ ├── ethers-addressbook v2.0.7
│ │ │ ├── ethers-core v2.0.7
│ │ ├── ethers-contract v2.0.7
│ │ │ ├── ethers-contract-abigen v2.0.7
│ │ │ │ ├── ethers-core v2.0.7 ()
│ │ │ ├── ethers-contract-derive v2.0.7 (proc-macro)
│ │ │ │ ├── ethers-contract-abigen v2.0.7 (
)
│ │ │ │ ├── ethers-core v2.0.7 ()
│ │ │ ├── ethers-core v2.0.7 (
)
│ │ │ ├── ethers-providers v2.0.7
│ │ │ │ ├── ethers-core v2.0.7 ()
│ │ ├── ethers-core v2.0.7 (
)
│ │ ├── ethers-etherscan v2.0.7
│ │ │ ├── ethers-core v2.0.7 ()
│ │ ├── ethers-middleware v2.0.7
│ │ │ ├── ethers-contract v2.0.7 (
)
│ │ │ ├── ethers-core v2.0.7 ()
│ │ │ ├── ethers-etherscan v2.0.7 (
)
│ │ │ ├── ethers-providers v2.0.7 ()
│ │ │ ├── ethers-signers v2.0.7
│ │ │ │ ├── ethers-core v2.0.7 (
)
│ │ ├── ethers-providers v2.0.7 ()
│ │ └── ethers-signers v2.0.7 (
)
│ ├── ethers-core v2.0.7 ()
│ ├── ethers-providers v2.0.7 (
)
│ ├── ethers-signers v2.0.7 ()
├── ethers-signers v2.0.7 (
)
├── ethers-signers v2.0.7 ()
├── ethers v2.0.7 (
)
├── ethers-core v2.0.7 ()
├── ethers-providers v2.0.7 (
)
├── ethers-signers v2.0.7 (*)

Platform
Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000 arm64

Description
I included ethers-core 2.0.7 in my build and got the following error when compiling:
error[E0015]: cannot call non-const fn ethabi::ethereum_types::U256::one in constant functions
--> /Users/chloenguyen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ethers-core-2.0.7/src/types/i256.rs:128:14
|
128 | Self(U256::one())
| ^^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants

@coffeeavax coffeeavax added the bug Something isn't working label Jun 29, 2023
@vdods
Copy link

vdods commented Jul 29, 2023

I'm getting this error too, and I've identified the problem. ethereum-types v0.14.1 depends on primitive-types v0.12 which depends on uint v0.9.0.

However, uint v0.9.0 (and up through v0.9.3) has its fn one defined without the const qualifier, whereas uint v0.9.4 has the const qualifier.

See https://docs.rs/uint/0.9.3/src/uint/uint.rs.html#795 and https://docs.rs/uint/0.9.4/src/uint/uint.rs.html#788

The solution is to require uint v0.9.4 or higher. This can be done at 3 different levels:

  • In your own crate. This is the easiest to do, since you control your own crate.
  • In the ethers-core crate, since this is where the error regarding const actually occurs.
  • In the ethereum-types crate, since it would be better if the type definitions it provided had maximal constness -- ultimately it belongs here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants