Groovy
  1. Groovy
  2. GROOVY-1299

Confusing and dangerous String->int conversion

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.0-JSR-4
    • Fix Version/s: None
    • Component/s: syntax
    • Labels:
      None
    • Environment:
      JSR4

      Description

      String s = "5"
      int x = s

      The effect of this code is that x is assigned the value of char '5'.

      String s = "10"
      int x = s

      This produces a runtime exception.

      If auto-conversion is absolutely needed between 1-character Strings and ints, then one would hope it would at least be limited to literal Strings. This behavior makes no sense.

        Activity

          People

          • Assignee:
            Guillaume Delcroix
            Reporter:
            John O'Malley
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development