Is dateAdd enforcement of params more strict in 5.4?

We have some older (embarrassing copy/paste or transposed param errors) running smoothly in 5.3.x (and prior) … and found some possibly-breaking-changes (fixes?) in 5.4

  • Most of these are within 3 years, once instance was 7 years ago so likely was ACF.

Is this intentional to enforce the correct parameter sequence?

  • If so, shouldn’t “case 1” also be failing?
<!--- Case 1: Add string (pass) --->
	<cfset myDate1_plus_90 = dateAdd("d", "2023-07-05", 90) />
	<cfdump var="#myDate1_plus_90#" label="case 1 pass" />

		<cfdump var="#cfcatch#" label="case 1 fail" />

<!--- Case 2: Add YYYY-MM-DD date string (fail) --->
	<cfset myDate2 = "2023-07-05" />
	<cfset myDate2_plus_90 = dateAdd("d", myDate2, 90) />
	<cfdump var="#myDate2_plus_90#" label="case 2 pass" />

		<cfdump var="#cfcatch#" label="case 2 fail" />

<!--- Case 3: Add Formatted date string (fail) --->
	<cfset myDate3 = dateFormat(now(), "yyyy-mm-dd") />
	<cfset myDate3_plus_90 = dateAdd("d", myDate3, 90) />
	<cfdump var="#myDate3_plus_90#" label="case 3 pass" />

		<cfdump var="#cfcatch#" label="case 3 fail" />

Top of the stack trace:

lucee.runtime.exp.CasterException: cannot cast [2023-07-05] string to a number value at lucee.runtime.op.Caster.toDoubleValue( at lucee.runtime.op.Caster.toDoubleValue( at index_cfm$cf$ 

Don’t forget to tell us about your stack!
OS: Windows 64-bit
Java Version: 11.0.7 (AdoptOpenJDK) 64bit
Tomcat Version: Tomcat/9.0.64
Lucee Version: Lucee

Edit: Added pass/fail/fail to respective test case comments in code. I would expect all to pass or all to fail.

First case raises an error in Lucee 6.0.0-SNAPSHOT+451 (beta) too.

1 Like

confirmed regression [LDEV-4616] - Lucee


the argument order is wrong btw

DateAdd( datePart=string, number=number, date=datetime );

Yep … thank you.
2nd and 3rd params swapped is certainly worth pointing out again though so others don’t copy my errors.

I’d even support drawing a line and saying “Won’t fix”. I have a code cleanup ticket (for my bad code) and am okay either way.