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

Incorrect line number reporting when exception occurs inside if statement

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.6-beta-2
    • 1.6-rc-1, 1.7-beta-1
    • bytecode
    • None

    Description

      The following code

      foo = new Foo()
      
      if(foo.hello()()) {
        println "do"
        println "do"
        println "do"
        println "do"      
      }
      
      
      class Foo {
         boolean hello() {true}
      }
      

      Produces the error

      groovy.lang.MissingMethodException: No signature of method: java.lang.Boolean.call() is applicable for argument types: () values: {}
      	at Script1.run(Script1:7)
      

      As you can see the line number says its line 7 (the closing bracket of the if) which is confusing as the actual problem is on line 3. I spent ages slowing ripping out more and more code inside a larger if trying to figure out what the problem was

      Attachments

        Issue Links

          Activity

            People

              blackdrag Jochen Theodorou
              graemerocher Graeme Rocher
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: