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

grammar ambiguity with ternary expression being confused with safe indexing

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.1
    • 4.0.0-alpha-1, 3.0.2
    • None
    • None

    Description

      The following works fine in 2.5.9 and 3.0.1:

      false ? ['abc'] : ['def']
      

      but the following onyl works in 2.5.9:

      true ? ["abc"] as String[] : new String[0]
      

      In 3.0.1 it gives:

      groovy.lang.MissingPropertyException: No such property: abc for class: java.lang.Boolean
      

      Attachments

        Activity

          People

            daniel_sun Daniel Sun
            paulk Paul King
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: