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

Generics compilation error occurs when using less then (<) operator

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.4, 1.7.5, 2.4.3, 2.5.2
    • 3.0.4
    • Compiler
    • None

    Description

      The following code is throwing a compilation error (the strange code is a DSL):

      def FloatComparison() {
          when:
          o.PROPerty1 < o.PROPerty2
          
          then:
          result = true
      }
      
      Missing closing bracket '>' for generics types;
         solution: Please specify the missing bracket! at line: 5, column: 5
      

      Here are some snippets that don't produce this error:

      def FloatComparison() {
          when:
          o.pROPerty1 < o.PROPerty2 //the first letter of the first variable is lowercase
          
          then:
          result = true
      }
      
      def FloatComparison() {
          when:
          o.PROPerty1 < o.PROPerty2
          
      //the label is removed and .x is added after result (without .x the exception occurs)
          result.x = true
      }
      

      Looking at the samples that work, this whole mess doesn't make any sense. It seems like a minor but very annoying bug in the compiler. We are working on a DSL, so we can't influence the names of the properties or anything significant that would be a proper workaround.

      (This is technically not a JUnit test case, but I think it's enough because it can be simply copied into the Groovy console and run)

      Attachments

        Activity

          People

            Unassigned Unassigned
            asandor asandor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: