Issues

Select view

Select search mode

 

concatenation operator fails inside cffinally inside a function

Description

if you have a function and are using the local scope inside a try/catch/finally, and use the string concatenation operator, it will generate an error “variable [local] doesn't exist”

 

Proof of concept:

<cffunction name="test"> <cfset local.thing = ""> <cfset local.thing &= "good"> <cftry> <cfset local.thing &= "better"> <cfcatch> <cfset local.thing &= "best"> </cfcatch> <cffinally> <cfset local.thing &= "fail"> </cffinally> </cftry> <cfset local.thing &= "end"> <cfreturn local.thing> </cffunction> <cfoutput>#test()#</cfoutput>

This will throw an error at line 10.

Environment

Windows

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 16 August 2022 at 16:40
Updated 17 August 2022 at 13:47

Activity

Show:

Pothys - MitrahSoft17 August 2022 at 13:41

It fails with a different error in the build
https://github.com/lucee/Lucee/runs/7879597732?check_suite_focus=true#step:20:1941

 

Stacktrace from the build

lucee.runtime.exp.NativeException: java.lang.Object cannot be cast to lucee.runtime.type.scope.Threads at lucee.runtime.type.scope.UndefinedImpl.getScopeFor(UndefinedImpl.java:340) at lucee.runtime.interpreter.VariableInterpreter.getVariableReference(VariableInterpreter.java:328) at lucee.runtime.op.OpUtil.unaryPreConcat(OpUtil.java:1251) at tickets.ldev4151_cfc$cf.udfCall(/test/tickets/LDEV4151.cfc:42) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)

Pothys - MitrahSoft17 August 2022 at 13:36
Edited

I've checked this ticket and confirmed the issue happened on the lucee latest version 5.3.10.56-SNAPSHOT. Using the compound concatenation operator(&=) in finally block with the local scope prefix throws an error like variable [local] doesn't exist. Seems it works fine in ACF.
Also using the concatenation operator(&) in finally block with/without the local scope prefix works fine in lucee too.

I added a testcase to this ticket
Pull Request: https://github.com/lucee/Lucee/pull/1766

Stacktrace

lucee.runtime.exp.ExpressionException: variable [local] doesn't exist at lucee.runtime.type.scope.UndefinedImpl.get(UndefinedImpl.java:242) at lucee.runtime.type.scope.UndefinedImpl.get(UndefinedImpl.java:184) at lucee.runtime.type.ref.VariableReference.get(VariableReference.java:90) at lucee.runtime.type.ref.VariableReference.get(VariableReference.java:83) at lucee.runtime.op.Operator.unaryPreConcat(Operator.java:1247) at test.testcases.ldev4151.test_cfm$cf$2.udfCall(/test/testcases/LDEV4151/test.cfm:17) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)

Flag notifications