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

Human readable (concise) output #416

Open
seanyoung opened this issue May 11, 2022 · 1 comment
Open

Human readable (concise) output #416

seanyoung opened this issue May 11, 2022 · 1 comment

Comments

@seanyoung
Copy link

The solang compiler uses this crate for integer literals, which can 256 bits in Solidity.

However formatting bigints with Display is not great.

contract c {
     int256 constant a = 1e1000;
}

gives the diagnostic:

error: literal 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 is too large to fit into type 'int256'

It would be nice if we had a .to_human_readable() function which would either use e notation or what solc does:

Error: Type int_const 1000...(993 digits omitted)...0000 is not implicitly convertible to expected type int256. Literal is too large to fit in int256.

This would work for large numbers which don't consist of lots of zeros too.

@cuviper
Copy link
Member

cuviper commented May 11, 2022

I think "human readable" is going to be highly subjective, not something I'm keen to bake in the API here.

Why doesn't the solang compiler report the literal value as it was originally written? Like:

error: literal 1e1000 is too large to fit into type 'int256'

I should also get back to num-bigint#214 for exponential formatting, but here I still think it's better to echo the literal back as given.

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

No branches or pull requests

2 participants