Compiler bug when finally contains for-in-loop

While migrating code from CF10, I found this bug. The error is thrown at compile time.
When finally contains a for-in loop, the compiler throws a NullPointerException.

try{
    foo;
}finally{
    for(a in b){}
}

The error occurs in Railo 4.2, Lucee 4.5 and Lucee 5: TryCF.com

Would be really cool if we could finally fix finally :slight_smile:

Related

Details
I was curious so I spent some time. I found 4 different stack traces dependent on the location of the example above:

  1. in a CFC in pseudo constructor (outside of UDFs)
  2. in CFC/CFM in a UDF
  3. in CFC/CFM in a UDF (> 10 udfs in source)
  4. in CFM

image

image

image

image

The Page class: Lucee/Page.java at 5.3.8.206 · lucee/Lucee · GitHub

The 4 cases call different methods on the GeneratorAdapter instance, but cause the same error.
The error occurs in MethodWriter.visitMaxs(…), the method has 250 loc and needs to be debugged at runtime (don’t know how).

GeneratorAdapter source
MethodWriter source

The dependency is a Require-Bundle of lucee.core: org.objectweb.asm.all; bundle-version=4.2

Version 4.2 is from 2013. Version 5.2 (2016) added support for Java 8 and had some fixes, maybe we can upgrade?

Changes in MethodWriter for 5.2