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

        John O'Malley created issue -
        John O'Malley made changes -
        Field Original Value New Value
        Status Open [ 1 ] Closed [ 6 ]
        Resolution Won't Fix [ 2 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12730442 ] Default workflow, editable Closed status [ 12742424 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12968844 ] Default workflow, editable Closed status [ 12976549 ]

          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