Colons (`:`) in function metadata is treated as and equal sign (`=`) instead of part of the identifier

Description

Lucee is treating colons as a separator like equal signs instead of part of the string identifier. Adobe processes this correctly.

Example code:

[TryCF Link](https://trycf.com/gist/708c836719e0c22af7b671fd70fee6a2/acf2016?theme=monokai)
```
<cfscript>
function foo() secured:api {}

writeDump( getMetadata( foo ) );
</cfscript>
```

Expected:
A key with `secured:api` as the name.

Actual:
Error: Value of attribute [secured] must have a literal/constant value on line 2

I’ve attached images from TryCF running this on Adobe and Lucee engines.

Environment

None

Attachments

2
  • 25 Apr 2022, 12:25 am
  • 25 Apr 2022, 12:25 am

Activity

Show:

Pothys - MitrahSoft 18 October 2022 at 08:25

I updated a testcase to this ticket
PR for 6.0 : https://github.com/lucee/Lucee/pull/1849

Adam Cameron 17 October 2022 at 18:58

A simpler case of the same situation is this:

component { function get(required numeric x) access=remote { return x; } }

Works fine in CF, errors with Value of attribute [access] must have a literal/constant value on Lucee (5.3.10.70-SNAPSHOT)

Zac Spitzer 1 June 2022 at 07:18

Brad Wood 25 April 2022 at 16:38

This difference in the Lucee parser is on purpose and Micha has addressed it before-- sadly it seems the old Railo ticket tracker no longer exists so I can’t find anywhere publicly where Micha has talked about this before. (MXUnit users used to run into this when trying to use the mxunit:expectedException annotation. Basically, the same parser that allows a struct literal to use either

{ foo = "bar" }

or

{ foo : "bar" }

is used for parsing additional key/values on component and function meta data. Therefore,

function foo() brad="wood" {}

is the same as

function foo() brad:"wood" {}

‘s argument in the past is that it was Adobe’s parser which was defective, and Lucee’s parser was the more consistent one, allowing colons in any context where key/value pairs were being built.

My preference would be to allow the “key” to be quoted just like in a struct, but that won’t help create cross-engine code as Adobe doesn’t allow that either currently.

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

Created 25 April 2022 at 00:25
Updated 28 October 2022 at 14:54

Flag notifications