groovy
  1. groovy
  2. GROOVY-5404

Compiler exception for invalid operator

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.8.6
    • Fix Version/s: 4.0
    • Component/s: class generator
    • Labels:
      None
    • Number of attachments :
      0

      Description

      A script containing this:

      print "Foo" ===~ ".*"

      ...causes the stack trace below from the compiler. It's not valid code of course, but the compiler should give a normal error message to the user.

      Stack trace:

      >>> a serious error occurred: BUG! exception in phase 'class generation' in source unit '<...>Foo.groovy' Operation: ("===" at 2:13: "===" ) not supported
      >>> stacktrace:
      BUG! exception in phase 'class generation' in source unit '/Users/jans/src/courses/nlp-class/week4/pa4-ner/java/GroovyTest.groovy' Operation: ("===" at 2:13: "===" ) not supported
      at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.eval(BinaryExpressionHelper.java:246)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression(AsmClassGenerator.java:521)
      at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:49)
      at org.codehaus.groovy.classgen.asm.CallSiteWriter.makeCallSite(CallSiteWriter.java:301)
      at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:187)
      at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:89)
      at org.codehaus.groovy.classgen.asm.InvocationWriter.makeInvokeMethodCall(InvocationWriter.java:73)
      at org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:292)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:657)
      at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:75)
      at org.codehaus.groovy.classgen.asm.StatementWriter.writeReturn(StatementWriter.java:577)
      at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeReturn(OptimizingStatementWriter.java:316)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:499)
      at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:47)
      at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:80)
      at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeBlockStatement(OptimizingStatementWriter.java:155)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:449)
      at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:101)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:112)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:313)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:270)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:390)
      at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1056)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:174)
      at org.codehaus.groovy.control.CompilationUnit$14.call(CompilationUnit.java:767)
      at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:967)
      at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:546)
      at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:524)
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:501)
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:480)
      at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:60)
      at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:216)
      at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:149)
      at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:179)
      at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:163)
      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.tools.GroovyStarter.rootLoader(GroovyStarter.java:108)
      at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)

        Activity

        Hide
        Tim Yates added a comment - - edited

        The operator === is in the Groovy grammar as the token IDENTICAL, but then it is not handled in the BinaryExpressionHelper.eval switch, so the GroovyBugError is thrown.

        The only reference I can find for it is from 2004:

        http://docs.codehaus.org/display/GroovyJSR/use+is+instead+of+triple+equals

        Where a request is made to remove === from Groovy as it is confusing.

        Seems this only partially happened...

        I wonder if it should it be removed from the grammar as well?

        Just checked, and back in the days of AsmClassGenerator, it used to throw the more helpful new SyntaxException("Operators === and !== are not supported. Use this.is(that) instead"...

        Show
        Tim Yates added a comment - - edited The operator === is in the Groovy grammar as the token IDENTICAL , but then it is not handled in the BinaryExpressionHelper.eval switch, so the GroovyBugError is thrown. The only reference I can find for it is from 2004: http://docs.codehaus.org/display/GroovyJSR/use+is+instead+of+triple+equals Where a request is made to remove === from Groovy as it is confusing. Seems this only partially happened... I wonder if it should it be removed from the grammar as well? Just checked, and back in the days of AsmClassGenerator, it used to throw the more helpful new SyntaxException("Operators === and !== are not supported. Use this.is(that) instead"...
        Hide
        blackdrag blackdrag added a comment -

        it actually happened fully, Alex Tkachman then requested its reintroduction for groovy++ and provided a patch doing so. Since groovy++ seems not to be something to consider anymore we can go and remove that operator again completely if we want to

        Show
        blackdrag blackdrag added a comment - it actually happened fully, Alex Tkachman then requested its reintroduction for groovy++ and provided a patch doing so. Since groovy++ seems not to be something to consider anymore we can go and remove that operator again completely if we want to
        blackdrag blackdrag made changes -
        Field Original Value New Value
        Issue Type Bug [ 1 ] Improvement [ 4 ]
        blackdrag blackdrag made changes -
        Fix Version/s 4.0 [ 18928 ]
        Hide
        blackdrag blackdrag added a comment -

        since 1.8.8 the bug error message is no longer reported, instead a GroovyRuntimeExcption containing the SyntaxException. The error reporting should be improved though, which is way I set the target to 4.0

        Show
        blackdrag blackdrag added a comment - since 1.8.8 the bug error message is no longer reported, instead a GroovyRuntimeExcption containing the SyntaxException. The error reporting should be improved though, which is way I set the target to 4.0

          People

          • Assignee:
            blackdrag blackdrag
            Reporter:
            Jan Stette
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: