groovy
  1. groovy
  2. GROOVY-3033

/= assignment operator breaks type system

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.6
    • Fix Version/s: 1.6.1, 1.5.8, 1.7-beta-1
    • Component/s: None
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      0

      Description

      while this works:
      groovy> long d = 100L
      groovy> d = d / 33L
      groovy> d.class

      Result: class java.lang.Long

      the following breaks the type system and produces a Long that is a BigDecimal!

      groovy> long d = 100L
      groovy> d /= 33L
      groovy> d.class

      Result: class java.math.BigDecimal

        Issue Links

          Activity

          Hide
          blackdrag blackdrag added a comment -

          long divided by long returns a BigDecimal in Groovy, this part is ok. What happens on the assignment is that the BigDecimal is converted into a long. This part is missing for /= it seems. So it is not a critical bug, but it is a bug

          Show
          blackdrag blackdrag added a comment - long divided by long returns a BigDecimal in Groovy, this part is ok. What happens on the assignment is that the BigDecimal is converted into a long. This part is missing for /= it seems. So it is not a critical bug, but it is a bug
          Hide
          blackdrag blackdrag added a comment -

          fixed

          Show
          blackdrag blackdrag added a comment - fixed

            People

            • Assignee:
              blackdrag blackdrag
              Reporter:
              Marco Ladermann
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: