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

Allow use of hex literals for uint types #4344

Open
Philogy opened this issue Nov 2, 2024 · 1 comment · May be fixed by #4387
Open

Allow use of hex literals for uint types #4344

Philogy opened this issue Nov 2, 2024 · 1 comment · May be fixed by #4387
Labels
VIP: Discussion Used to denote VIPs and more complex issues that are waiting discussion in a meeting

Comments

@Philogy
Copy link
Contributor

Philogy commented Nov 2, 2024

Simple Summary

Vyper doesn't allow to do the following:

MY_CONSTANT: constant(uint128) = 0xffffffffffffffffffffffffffffffff

Sometimes it's more convenient/clear to use hex as literals for units, disallowing this seems unnecessary/is annoying.

Motivation

Make Vyper easier to use.

Specification

Remove this error and allowing casting of hex literals to uint types.

Backwards Compatibility

Backwards compatible because this was previously disallowed meaning no valid contracts contained this.

Dependencies

None.

References

None.

Copyright

Copyright and related rights waived via CC0

@Philogy Philogy added the needs triage needs triage label Nov 2, 2024
@charles-cooper charles-cooper added VIP: Discussion Used to denote VIPs and more complex issues that are waiting discussion in a meeting and removed needs triage needs triage labels Nov 4, 2024
@charles-cooper
Copy link
Member

charles-cooper commented Nov 4, 2024

in the 0.3.x series (0.3.0 i think), i disallowed literals from being allowed in multiple type classes. it was to simplify the typechecker code. we could relax that, but just giving you the historical and implementation context for why the rules are currently the way they are.

that being said, having to do stuff convert(0xffff, uint16) is indeed kind of annoying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VIP: Discussion Used to denote VIPs and more complex issues that are waiting discussion in a meeting
Projects
None yet
2 participants