Inability to refer to static members dynamically

Description

I would expect the ability to refer to static members dynamically, either the component name, the member name or both.

Examples (and errors received)

//testStatic.cfc component { static { f = () -> true; } }
//index.cfm <cfscript> c = "testStatic"; m = "f"; dump(testStatic::f()); //normal syntax, not dynamic //dump(testStatic::[m]()); //invalid identifier //dump(testStatic::"f"()); //invalid identifier //dump(testStatic::["f"]()); //invalid identifier //dump(testStatic::"#m#"()); //invalid identifier //dump([c]::f()); //Syntax Error, Invalid Construct </cfscript>

I don't necessarily expect all of those syntaxes to work, but was just trying to see if there was any way to make it work.

My preferred syntax would be that anything in brackets would be evaluated:

[c]::[m]()

Environment

None

Attachments

1
  • 03 Mar 2017, 02:46 am

Activity

Julian Halliwell 25 October 2018 at 13:34

Just to note that there is now a workaround allowing dynamic paths to static members : https://luceeserver.atlassian.net/browse/LDEV-1254

Denard Springle 3 March 2017 at 02:51
Edited

I"m on 5.1.1.65 and am still getting errors trying to dynamically instantiate a CFC to call it's static methods. See attached test case which demonstrates everything I've tried.

Significantly, this code:

data = [ dynamicPath ]::getData();

throws a compile time error: Missing [;] or [line feed] after expression

In this code, `[ dynamicPath ]` should evaluate to `model.static`

Compile time errors are commented out individually so you can test each case.

Either I'm doing something wrong here or this still is not working for me

Fixed

Details

Assignee

Reporter

Priority

Fix versions

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 8 April 2015 at 13:04
Updated 5 May 2023 at 09:40
Resolved 10 November 2015 at 15:16