Skip to content

non-address hex literals cannot be assigned to uint256 #15468

Open
@haoyang9804

Description

@haoyang9804

Description

As described in Address Literals, hex literals of the correct size that pass the checksum test are of address type.
An incorrect size of 38 can be converted to uint256, but a correct size of 39 that fail the checksum cannot be converted to uint256, which is confusing.

Environment

  • Compiler version: 0.8.28
  • Operating system: macos

Steps to Reproduce

Below is the reproducible test program:

function f() {
  address adr = 0xde74fE3E9482D11dAeBE981C1f5Bf1e5E3055c31; // pass
  address adr2 = 0xde74fE3E9482D11dAeBE981C1f5Bf1e5E3055c3; // fail
  uint256 a = 0xde74fE3E9482D11dAeBE981C1f5Bf1e5E3055c3; // fail
  uint256 b = 0xde74fE3E9482D11dAeBE981C1f5Bf1e5E3055c; // pass
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions