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

Non-int untyped numeric literal #95

Closed
tv42 opened this issue Sep 7, 2022 · 2 comments
Closed

Non-int untyped numeric literal #95

tv42 opened this issue Sep 7, 2022 · 2 comments

Comments

@tv42
Copy link

tv42 commented Sep 7, 2022

Go constants are larger than int ("Represent integer constants with at least 256 bits." https://go.dev/ref/spec#Constants). If you try to use .Lit with even int64, jennifer makes it a typed constant.

Maybe .Lit should support math/big, and just insert the stringification as literal value -- those non-builtin types can never be typed constants, so there's no other possible interpretation.

@tv42
Copy link
Author

tv42 commented Sep 7, 2022

Maybe if the caller wants a conversion, the caller should ask for a conversion..

@dave
Copy link
Owner

dave commented Sep 7, 2022

I don't think this is a huge problem in real-world usage... Probably not big enough to further complicate the library. If you really need to emit a numeric const that overflows int, you could kludge it with Id - something like:

jen.Const().Id("BigNumber").Op("=").Id("100000000000000000000000")

@dave dave closed this as not planned Won't fix, can't repro, duplicate, stale Aug 3, 2023
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