Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4421

Casts should have higher precedence than mathematical operators

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 1.7.4
    • Fix Version/s: 2.4.4
    • Component/s: Compiler
    • Labels:
      None

      Description

      The following test case executes successfully when compiled+executed as java. However it throws the exception "Cannot use mod() on this number type: java.math.BigDecimal with value: 10.7" when executed as groovy.

      public class TesCastPrecedence {
          @org.junit.Test
          public void testCastWithMod() {
              long result = (long)10.7 % 3L;
              System.out.println(result);
              org.junit.Assert.assertEquals(result, 1L);
          }
      }
      

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              jwadamson Jeffrey Adamson
            • Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: