-
Notifications
You must be signed in to change notification settings - Fork 194
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
compiler crashes with integer overflow when evaluating expressions #54
Comments
also, would you accept a patch to fix this? |
We are evaluating the expression because it is part of our tree simplifying pass where we 'preevaluate' constant expressions the runtime error is a bit weird, soy does most of its calculations on integers using java longs, but at various points we assert that it isn't 'too big' I believe the goal is all about server/client consistency. We don't want a server rendered template to give different results because it has higher precision integers (64 vs. 52 bits). imho it is a bit misguided, but I also didn't add these checks so i am not entirely sure about the motivation. @Ubehebe any opinion on this? |
ok, just took a quicker look at the specific code in question and there are additional bits of weirdness. apparently soy only allows integer constants to be declared if they fit in 32 bits. as a work around you should be able to add a '.0' suffix to any one of those numbers and flip into double math. imho we should probably just switch all soy integer math to use 'long's instead of ints. There are a few places where we need 'int's (like indexing into collections), but unchecked downcasts should be fine in those places. |
fwiw, there's already an exception catch that tells the simplifier to back off and leave the expression alone. closure-templates/java/src/com/google/template/soy/sharedpasses/opti/SimplifyExprVisitor.java Line 231 in 50a0b69
I was going to suggest that we move the |
Crashes with the following exception:
Reproduced with the compiler at head.
This is perfectly valid javascript because numbers are doubles? And in Java, it should convert to double or long?
Relatedly, it's not clear to me why the soy compiler is trying to evaluate the expression at all? This seems like something the Java or JS compiler would be more effective at.
The text was updated successfully, but these errors were encountered: