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

Inscrutable error message on missing comma

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • syntax
    • None
    • Debian Testing, Groovy HEAD a4bf2c97e62c687e2becabc09547cfe49bbc2603

    Description

      The code:

      def task ( name , block ) { print name ; block ( ) }
      task 'hello' , { println ' calling . . . ' }
      

      compiles and runs fine in GroovyConsole. However missing the comma in the call:

      task 'hello' { println ' calling . . . ' }
      

      leads to the error message:

      groovy.lang.MissingPropertyException: No such property: task for class: ConsoleScript2
      Possible solutions: class
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
      at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
      at ConsoleScript2.run(ConsoleScript2:2)
      at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:255)
      at groovy.lang.GroovyShell.run(GroovyShell.java:506)
      at groovy.lang.GroovyShell.run(GroovyShell.java:161)
      at groovy.lang.GroovyShell$run.call(Unknown Source)
      at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy:924)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:882)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
      at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:882)
      at groovy.lang.Closure.call(Closure.java:410)
      at groovy.lang.Closure.call(Closure.java:404)
      at groovy.lang.Closure.run(Closure.java:488)
      at java.lang.Thread.run(Thread.java:662)

      groovy.lang.MissingPropertyException: No such property: task for class: ConsoleScript2
      Possible solutions: class
      at ConsoleScript2.run(ConsoleScript2:2)

      which really gives no indication at all to the programmer what has gone wrong. The error message is far too related to the parse of the line and unrelated to the programmers original source code.

      Attachments

        Activity

          People

            Unassigned Unassigned
            russel Dr. Russel Winder
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: