jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • groovy
  • GROOVY-338

Error message for out of scope variables

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0-beta-4
  • Fix Version/s: 1.0-JSR-5
  • Component/s: class generator
  • Labels:
    None

Description

This code

void testUno() {

try { s = "bbb"; } finally { s.trim(); }

}

throws this exception

Failed to invoke suite(): java.lang.VerifyError: (class: ProvaTest, method: testUno signature: ()V) Register 1 contains wrong type

I think this code should fail with a "No such property: s", "s is out of scope" or something like that.

Issue Links

is depended upon by

Task - A task that needs to be done. GROOVY-760 improve error reporting

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
blackdrag blackdrag added a comment - 10/Jun/05 7:35 AM

if you enable the compiler checks in JSR-2 and write the method as part of a class, then groovy will inform you that s is undeclared two times. One for s="bbb" and the other for s.trim(). For scripts I am unsure how to solve this

Show
blackdrag blackdrag added a comment - 10/Jun/05 7:35 AM if you enable the compiler checks in JSR-2 and write the method as part of a class, then groovy will inform you that s is undeclared two times. One for s="bbb" and the other for s.trim(). For scripts I am unsure how to solve this
Hide
Permalink
Wang Bin added a comment - 13/Jun/05 4:20 AM

See
https://bugs.eclipse.org/bugs/show_bug.cgi?id=36246

This may be a bug in Sun's bytecode verification implementation.

Show
Wang Bin added a comment - 13/Jun/05 4:20 AM See https://bugs.eclipse.org/bugs/show_bug.cgi?id=36246 This may be a bug in Sun's bytecode verification implementation.
Hide
Permalink
Russel Winder added a comment - 13/Jun/05 5:21 AM

It may well turn out to be a verifier problem but the question is why is Groovy getting this? The Java code:

public class GROOVY_338 {
String s = "" ;
public void testUno ( ) {
try { s = "bbb" ; } finally { s.trim ( ) ; }
}
}

compiles fine whereas the Groovy script:

String s = "" ;
void testUno ( ) {
try { s = "bbb" ; } finally { s.trim ( ) ; }
}

which should, in principle be the same causes :

Caught: java.lang.VerifyError: (class: GROOVY_338, method: testUno signature: ()V) Register 1 contains wrong type

running on JDK1.5.0_03. So the problem is not the code per se but the way in which Groovy handles the code. Interestingly, or not, the Groovy class:

class GROOVY_338 {
String s = "" ;
void testUno ( ) {
try { s = "bbb" ; } } finally { s.trim ( ) ; }
}
}

compiles fine (bur fails to execute as there is no main.

Show
Russel Winder added a comment - 13/Jun/05 5:21 AM It may well turn out to be a verifier problem but the question is why is Groovy getting this? The Java code: public class GROOVY_338 { String s = "" ; public void testUno ( ) { try { s = "bbb" ; } finally { s.trim ( ) ; } } } compiles fine whereas the Groovy script: String s = "" ; void testUno ( ) { try { s = "bbb" ; } finally { s.trim ( ) ; } } which should, in principle be the same causes : Caught: java.lang.VerifyError: (class: GROOVY_338, method: testUno signature: ()V) Register 1 contains wrong type running on JDK1.5.0_03. So the problem is not the code per se but the way in which Groovy handles the code. Interestingly, or not, the Groovy class: class GROOVY_338 { String s = "" ; void testUno ( ) { try { s = "bbb" ; } } finally { s.trim ( ) ; } } } compiles fine (bur fails to execute as there is no main.
Hide
Permalink
blackdrag blackdrag added a comment - 14/Jun/05 12:47 PM

it's possible that the String s= "" is not seen because the field is private and groovy has problems when accessing private fields. If so then the s="bbb" would declare a variable s for the try part which is invisible for the finally part... maybe some part in ACG does not know this and tries to access a nonexistant local var...

Show
blackdrag blackdrag added a comment - 14/Jun/05 12:47 PM it's possible that the String s= "" is not seen because the field is private and groovy has problems when accessing private fields. If so then the s="bbb" would declare a variable s for the try part which is invisible for the finally part... maybe some part in ACG does not know this and tries to access a nonexistant local var...
Hide
Permalink
blackdrag blackdrag added a comment - 19/Jan/06 4:12 PM

the new bahaivior is that the code will fail in a class since s is not defined first. In a script the method does now use the binding, which menas s is available

Show
blackdrag blackdrag added a comment - 19/Jan/06 4:12 PM the new bahaivior is that the code will fail in a class since s is not defined first. In a script the method does now use the binding, which menas s is available

People

  • Assignee:
    blackdrag blackdrag
    Reporter:
    lorenzo
Vote (0)
Watch (0)

Dates

  • Created:
    28/Mar/04 5:11 PM
    Updated:
    19/Jan/06 4:12 PM
    Resolved:
    19/Jan/06 4:12 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.