I need to create unique contactCodes via API. The API is picky about strings vs numerics. Strings must be single-quoted, numeric can’t be. I’m using hyper to make these requests. In the code below, if I don’t try to enclose the padded code using “‘#()#’”, it works. If I do it this way, I get the following error:
@Daemach Your example is uneccessarily complex. I can reproduce the error with just this code:
"'#foo &= ""#'"
I’d enter a ticket.
While simplfying your example, I also ran into this odd error
foo &= (1 ? "" : "")
produces this error:
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:339)
at lucee.runtime.interpreter.VariableInterpreter.getVariableReference(VariableInterpreter.java:319)
at lucee.runtime.op.Operator.unaryPreConcat(Operator.java:1259)
at page$cf$278.call(/page.cfm:1)
Is this trying trying to output a variable (that doesn’t exist) called foo &= " ?
Or is it trying to be clever and set foo to something if it doesn’t exist ? In an odd way…
So the title is a bit scary but it’s fine. I mean, not fine but ‘all right unless you are doing something like rendering untrusted variable names or weird code syntax tricks’
And the work around is to make the bit between the hash marks from the original much less complicated ?
Perhaps you were thrown off by the fact foo wasn’t declared prior. That would be an issue if the code compiled it would throw an error that the variable foo didn’t exist. But since the code doesn’t even compile, I didn’t even bother initializing the variable in the example as it wasn’t necessary to the repro case.
The ? in my second example is just a ternary statement
boolean ? 'if true' : 'if false'
Since you didn’t use any code blocks, I’m not quite sure if you were just using ? to ask a question or if you were referring to that part of the code