-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: Fixes issue 3453, string literal input formats for Int128 & Uint128 #4813
Conversation
engaging autolinker: #3453 |
I would just remove the quoting, so the conversion from string to int is done at macro-expand time. |
Is this a finished pull request, or should we expect parser changes to emit macro calls when large integer literals occur in Julia source? |
I originally thought of this as finished, but I've recently been making progress in changing the parser. I'm hoping to push changes in the next day or so. I guess I should have labeled this as a WIP instead. |
No problem. Just wanted to be sure. Looking forward to the rest. |
Okay, I think I've finished the modifications. @StefanKarpinski, I ended up not needing to use the macros. I'm thinking of removing them, but would they be useful in other contexts? |
Oo! Impressive work. Taking a look. cc: @JeffBezanson |
Ok, I think I found a bug: julia> 106301099528559113985750943957626130432881762387162312
-106301099528559113985750943957626130432881762387162312 |
And yes, I just typed a lot of random digits. |
Hmm, I should have tested before I pushed. I've seen this bug before! I thought I fixed it. Taking another look. |
I don't think parsing these as function calls is going to fly. Parsing Int128s directly is tractable, since this type is defined very early (in |
That's why I recommended emitting macro calls instead. |
@StefanKarpinski Like this? (Sorry, I'm very much a beginner at all this.) |
No worries, this is good work and this is not an unusual amount of back-and-forth for a change like this. |
Here's another issue: julia> -0x00000000000000001
ERROR: invalid base-10 digit '-' in "-0x00000000000000001"
julia> :(-0x00000000000000001)
:(-(@uint128_str "-0x00000000000000001")) |
Here's another one: julia> 0b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0x00000000000000000000000000000000
julia> typeof(ans)
Uint128 Same thing with hex and octal versions. |
I should note that that's |
@JeffBezanson, any thoughts? I'm ready to pull the trigger on this. |
BigInts in ASTs might be a problem since we can't save them in the system image due to their use of native pointers. |
Yeah, the BigInt literals are the ones I'm the least sold on. Saving them to the system image shouldn't be a problem unless we use this functionality while building the system image, right? |
Fixes issue 3453, string literal input formats for Int128 & Uint128 Note that this requires at least a `make clean`.
I now have the trouble that random.jl during creation of sys.ji has a dependency with BigInt via Base.Random.uuid4().
fixes this for me, so there might be a dependency hidden which is connected to integer parsing. Warning: 32 bit system here. |
Those aren't BigInts – they're Uint128 literals, which should work without any issues, but yes, I'm not too surprised that's not entirely hiccup-free on a 32-bit system. Can you open an issue and give more detail about the problem? Sorry that master is such a mess for you right now – hopefully we can get it sorted out soon. |
You're not the only one: c415d04#commitcomment-4870539. |
It would really be better to implement literals entirely in the front end. On 64-bit systems we have |
That feedback would have been helpful anytime in the past month. |
The problem is there is no easy way to proceed with that approach, due to a general paucity of Int128 support throughout the stack. And for BigInt the situation is even worse. The implementation of BigInt literals we have now is the only thing that will work, aside from rewriting the parser in julia, or building BigInts deeper into the system. And even then there is still the problem of saving the pointers inside them. |
So it sounds like this approach – since it actually works – was a good one. It appealed to me since it was minimally invasive, which is usually a pretty decent heuristic. |
See #3453. string literal input formats for Int128 & Uint128.