Any of you ever see an error like this? I getting ...
# lucee
i
Any of you ever see an error like this? I getting it on trycf when passing a variable that uses safe path operator into arrayLen (https://trycf.com/gist/6ffdae68dc6a89017042e64b42ed8fb3/lucee5?theme=monokai) :
Expecting a stackmap frame at branch target 55 Exception Details: Location: main1683037896331_ebf01615_d507_cc4a_2dd2_6c6bc52d4398_cfm7020$cf$3e4.call(Llucee/runtime/PageContext;)Ljava/lang/Object; @5: iconst_1 Reason: Expected stackmap frame at this location. Bytecode: 0x0000000: 2bb6 003c 4d04 9900 2e2b 2b2b 2b2b 2bb6 0x0000010: 0040 2ab4 0042 0332 01b6 0046 b200 4c01 0x0000020: b600 462a b400 4204 3201 b600 4fb8 0055 0x0000030: b800 5a58 a700 a04e 2db8 0060 9900 052d 0x0000040: bf2d b800 643a 042b 1904 0404 b600 682b 0x0000050: 126a b600 6e2b b600 722a b400 4205 322b 0x0000060: 2bb6 0072 2ab4 0042 0632 05bd 0074 5903 0x0000070: 2bb6 0072 b200 77b9 007c 0200 5359 0412 0x0000080: 7e53 b600 82b9 0086 0300 572b 126a b600 0x0000090: 6e2b b600 892b 2b14 008a b800 90b6 006e 0x00000a0: 2b2b 2bb6 0072 2ab4 0042 0532 b900 7c02 0x00000b0: 00b8 0095 b600 6ea7 000c 3a05 2bb6 0098 0x00000c0: 1905 bf2b b600 98a7 000d 3a06 2b2c b600 0x00000d0: 9b19 06bf 2b2c b600 9b01 b0 Exception Handler Table: bci [5, 52] => handler: 55 bci [149, 186] => handler: 186 bci [5, 199] => handler: 202
z
i
Yeah, way better thanks. ("Can't cast Null value to value of type [Array] on line 3")
z
yeah those bytecode errors are horrible (for everyone)
🤣 1
r
Interesting. If you replace arrayLen() with isNull() it still fails in Lucee 5 but returns true in Lucee 6, as expected.
i
The byte code error itself was fixed too, not just the error message. This works lucee 6 too but not 5: arrayLen(local?.coursesResponse?.data?.courses ?: []) (which is what I was originally doing that kicked this off). It never gets past local?.coursesResponse?.data?.courses so it never defaults to []
b
There's a ticket for this
🙌 1
Safe nav in Lucee has always been sketchy and I avoid it
If you're putting an elvis at the end, you don't even need it
i
@bdw429s writeDump(arrayLen(local.test) ?: 0) this errors because local.test doesn't exist. writeDump(arrayLen(local?.test) ?: 0) on lucee 6. Are you saying the first example should work without (?.)? Maybe you mean this: writeDump(arrayLen(local.test ?: []))
b
You want
Copy code
Arraylen( local.test ?: [] )
i
Yeah that works great. Thanks.
b
See, safe nav is almost never needed 😁
🙌 1
Elvis will always "eat" any nulls on the left hand side, even early in the expression.
g
Elvis - always eating..
🙂 1
i
@bdw429s Shouldn't this work if it always eats lhs? https://trycf.com/gist/a2079ffe1657ebf77b0cb6c54dc53729/lucee5?theme=monokai
b
@ian.hickey Yes, that should work. See these tickets in the Lucee ticket tracker from 6 years ago 😕 https://luceeserver.atlassian.net/browse/LDEV-1522 https://luceeserver.atlassian.net/browse/LDEV-1201
One of those tickets was marked resolved, but the comments from users telling them it was still broken were basically ignored.
Yes, I'm bitter 😆
🤣 1
Please comment and vote
🙌 1